@pnp/cli-microsoft365 6.2.0-beta.d5442a1 → 6.2.0-beta.edaa477
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.
- package/dist/m365/onenote/commands/page/page-list.js +137 -0
- package/dist/m365/onenote/commands.js +2 -1
- package/dist/m365/purview/commands/retentionlabel/retentionlabel-add.js +143 -0
- package/dist/m365/purview/commands.js +1 -0
- package/dist/m365/spo/commands/file/file-sharinglink-get.js +116 -0
- package/dist/m365/spo/commands/file/file-sharinglink-list.js +17 -4
- package/dist/m365/spo/commands/file/file-sharinglink-remove.js +135 -0
- package/dist/m365/spo/commands/group/group-member-add.js +33 -6
- package/dist/m365/spo/commands/term/term-list.js +99 -29
- package/dist/m365/spo/commands.js +2 -0
- package/docs/docs/cmd/onenote/page/page-list.md +140 -0
- package/docs/docs/cmd/purview/retentionlabel/retentionlabel-add.md +128 -0
- package/docs/docs/cmd/spo/file/file-sharinglink-get.md +107 -0
- package/docs/docs/cmd/spo/file/file-sharinglink-list.md +16 -7
- package/docs/docs/cmd/spo/file/file-sharinglink-remove.md +52 -0
- package/docs/docs/cmd/spo/group/group-member-add.md +22 -4
- package/docs/docs/cmd/spo/term/term-list.md +138 -0
- package/package.json +1 -1
|
@@ -0,0 +1,137 @@
|
|
|
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 _OneNotePageListCommand_instances, _OneNotePageListCommand_initTelemetry, _OneNotePageListCommand_initOptions, _OneNotePageListCommand_initValidators, _OneNotePageListCommand_initOptionSets;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const request_1 = require("../../../../request");
|
|
19
|
+
const odata_1 = require("../../../../utils/odata");
|
|
20
|
+
const validation_1 = require("../../../../utils/validation");
|
|
21
|
+
const aadGroup_1 = require("../../../../utils/aadGroup");
|
|
22
|
+
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
23
|
+
const commands_1 = require("../../commands");
|
|
24
|
+
class OneNotePageListCommand extends GraphCommand_1.default {
|
|
25
|
+
get name() {
|
|
26
|
+
return commands_1.default.PAGE_LIST;
|
|
27
|
+
}
|
|
28
|
+
get description() {
|
|
29
|
+
return 'Retrieve a list of OneNote pages.';
|
|
30
|
+
}
|
|
31
|
+
defaultProperties() {
|
|
32
|
+
return ['createdDateTime', 'title', 'id'];
|
|
33
|
+
}
|
|
34
|
+
constructor() {
|
|
35
|
+
super();
|
|
36
|
+
_OneNotePageListCommand_instances.add(this);
|
|
37
|
+
__classPrivateFieldGet(this, _OneNotePageListCommand_instances, "m", _OneNotePageListCommand_initTelemetry).call(this);
|
|
38
|
+
__classPrivateFieldGet(this, _OneNotePageListCommand_instances, "m", _OneNotePageListCommand_initOptions).call(this);
|
|
39
|
+
__classPrivateFieldGet(this, _OneNotePageListCommand_instances, "m", _OneNotePageListCommand_initValidators).call(this);
|
|
40
|
+
__classPrivateFieldGet(this, _OneNotePageListCommand_instances, "m", _OneNotePageListCommand_initOptionSets).call(this);
|
|
41
|
+
}
|
|
42
|
+
getEndpointUrl(args) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
let endpoint = `${this.resource}/v1.0/`;
|
|
45
|
+
if (args.options.userId) {
|
|
46
|
+
endpoint += `users/${args.options.userId}`;
|
|
47
|
+
}
|
|
48
|
+
else if (args.options.userName) {
|
|
49
|
+
endpoint += `users/${args.options.userName}`;
|
|
50
|
+
}
|
|
51
|
+
else if (args.options.groupId) {
|
|
52
|
+
endpoint += `groups/${args.options.groupId}`;
|
|
53
|
+
}
|
|
54
|
+
else if (args.options.groupName) {
|
|
55
|
+
const groupId = yield this.getGroupId(args.options.groupName);
|
|
56
|
+
endpoint += `groups/${groupId}`;
|
|
57
|
+
}
|
|
58
|
+
else if (args.options.webUrl) {
|
|
59
|
+
const siteId = yield this.getSpoSiteId(args.options.webUrl);
|
|
60
|
+
endpoint += `sites/${siteId}`;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
endpoint += 'me';
|
|
64
|
+
}
|
|
65
|
+
endpoint += '/onenote/pages';
|
|
66
|
+
return endpoint;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
getGroupId(groupName) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
const group = yield aadGroup_1.aadGroup.getGroupByDisplayName(groupName);
|
|
72
|
+
return group.id;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
getSpoSiteId(webUrl) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const url = new URL(webUrl);
|
|
78
|
+
const requestOptions = {
|
|
79
|
+
url: `${this.resource}/v1.0/sites/${url.hostname}:${url.pathname}`,
|
|
80
|
+
headers: {
|
|
81
|
+
accept: 'application/json;odata.metadata=none'
|
|
82
|
+
},
|
|
83
|
+
responseType: 'json'
|
|
84
|
+
};
|
|
85
|
+
const site = yield request_1.default.get(requestOptions);
|
|
86
|
+
return site.id;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
commandAction(logger, args) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
try {
|
|
92
|
+
const endpoint = yield this.getEndpointUrl(args);
|
|
93
|
+
const items = yield odata_1.odata.getAllItems(endpoint);
|
|
94
|
+
logger.log(items);
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
this.handleRejectedODataJsonPromise(err);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
_OneNotePageListCommand_instances = new WeakSet(), _OneNotePageListCommand_initTelemetry = function _OneNotePageListCommand_initTelemetry() {
|
|
103
|
+
this.telemetry.push((args) => {
|
|
104
|
+
Object.assign(this.telemetryProperties, {
|
|
105
|
+
userId: typeof args.options.userId !== 'undefined',
|
|
106
|
+
userName: typeof args.options.userName !== 'undefined',
|
|
107
|
+
groupId: typeof args.options.groupId !== 'undefined',
|
|
108
|
+
groupName: typeof args.options.groupName !== 'undefined',
|
|
109
|
+
webUrl: typeof args.options.webUrl !== 'undefined'
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}, _OneNotePageListCommand_initOptions = function _OneNotePageListCommand_initOptions() {
|
|
113
|
+
this.options.unshift({ option: '--userId [userId]' }, { option: '--userName [userName]' }, { option: '--groupId [groupId]' }, { option: '--groupName [groupName]' }, { option: '-u, --webUrl [webUrl]' });
|
|
114
|
+
}, _OneNotePageListCommand_initValidators = function _OneNotePageListCommand_initValidators() {
|
|
115
|
+
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
if (args.options.userId && !validation_1.validation.isValidGuid(args.options.userId)) {
|
|
117
|
+
return `${args.options.userId} is not a valid GUID`;
|
|
118
|
+
}
|
|
119
|
+
if (args.options.groupId && !validation_1.validation.isValidGuid(args.options.groupId)) {
|
|
120
|
+
return `${args.options.groupId} is not a valid GUID`;
|
|
121
|
+
}
|
|
122
|
+
if (args.options.webUrl) {
|
|
123
|
+
return validation_1.validation.isValidSharePointUrl(args.options.webUrl);
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
126
|
+
}));
|
|
127
|
+
}, _OneNotePageListCommand_initOptionSets = function _OneNotePageListCommand_initOptionSets() {
|
|
128
|
+
this.optionSets.push({
|
|
129
|
+
options: ['userId', 'userName', 'groupId', 'groupName', 'webUrl'],
|
|
130
|
+
runsWhen: (args) => {
|
|
131
|
+
const options = [args.options.userId, args.options.userName, args.options.groupId, args.options.groupName, args.options.webUrl];
|
|
132
|
+
return options.some(item => item !== undefined);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
module.exports = new OneNotePageListCommand();
|
|
137
|
+
//# sourceMappingURL=page-list.js.map
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const prefix = 'onenote';
|
|
4
4
|
exports.default = {
|
|
5
|
-
NOTEBOOK_LIST: `${prefix} notebook list
|
|
5
|
+
NOTEBOOK_LIST: `${prefix} notebook list`,
|
|
6
|
+
PAGE_LIST: `${prefix} page list`
|
|
6
7
|
};
|
|
7
8
|
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1,143 @@
|
|
|
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 _PurviewRetentionLabelAddCommand_instances, _PurviewRetentionLabelAddCommand_initTelemetry, _PurviewRetentionLabelAddCommand_initOptions, _PurviewRetentionLabelAddCommand_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 PurviewRetentionLabelAddCommand extends GraphCommand_1.default {
|
|
22
|
+
get name() {
|
|
23
|
+
return commands_1.default.RETENTIONLABEL_ADD;
|
|
24
|
+
}
|
|
25
|
+
get description() {
|
|
26
|
+
return 'Create a retention label';
|
|
27
|
+
}
|
|
28
|
+
constructor() {
|
|
29
|
+
super();
|
|
30
|
+
_PurviewRetentionLabelAddCommand_instances.add(this);
|
|
31
|
+
__classPrivateFieldGet(this, _PurviewRetentionLabelAddCommand_instances, "m", _PurviewRetentionLabelAddCommand_initTelemetry).call(this);
|
|
32
|
+
__classPrivateFieldGet(this, _PurviewRetentionLabelAddCommand_instances, "m", _PurviewRetentionLabelAddCommand_initOptions).call(this);
|
|
33
|
+
__classPrivateFieldGet(this, _PurviewRetentionLabelAddCommand_instances, "m", _PurviewRetentionLabelAddCommand_initValidators).call(this);
|
|
34
|
+
}
|
|
35
|
+
commandAction(logger, args) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const retentionTrigger = args.options.retentionTrigger ? args.options.retentionTrigger : 'dateLabeled';
|
|
38
|
+
const defaultRecordBehavior = args.options.defaultRecordBehavior ? args.options.defaultRecordBehavior : 'startLocked';
|
|
39
|
+
const requestBody = {
|
|
40
|
+
displayName: args.options.displayName,
|
|
41
|
+
behaviorDuringRetentionPeriod: args.options.behaviorDuringRetentionPeriod,
|
|
42
|
+
actionAfterRetentionPeriod: args.options.actionAfterRetentionPeriod,
|
|
43
|
+
retentionTrigger: retentionTrigger,
|
|
44
|
+
retentionDuration: {
|
|
45
|
+
'@odata.type': '#microsoft.graph.security.retentionDurationInDays',
|
|
46
|
+
days: args.options.retentionDuration
|
|
47
|
+
},
|
|
48
|
+
defaultRecordBehavior: defaultRecordBehavior
|
|
49
|
+
};
|
|
50
|
+
if (args.options.descriptionForAdmins) {
|
|
51
|
+
if (this.verbose) {
|
|
52
|
+
logger.logToStderr(`Using '${args.options.descriptionForAdmins}' as descriptionForAdmins`);
|
|
53
|
+
}
|
|
54
|
+
requestBody.descriptionForAdmins = args.options.descriptionForAdmins;
|
|
55
|
+
}
|
|
56
|
+
if (args.options.descriptionForUsers) {
|
|
57
|
+
if (this.verbose) {
|
|
58
|
+
logger.logToStderr(`Using '${args.options.descriptionForUsers}' as descriptionForUsers`);
|
|
59
|
+
}
|
|
60
|
+
requestBody.descriptionForUsers = args.options.descriptionForUsers;
|
|
61
|
+
}
|
|
62
|
+
if (args.options.labelToBeApplied) {
|
|
63
|
+
if (this.verbose) {
|
|
64
|
+
logger.logToStderr(`Using '${args.options.labelToBeApplied}' as labelToBeApplied...`);
|
|
65
|
+
}
|
|
66
|
+
requestBody.labelToBeApplied = args.options.labelToBeApplied;
|
|
67
|
+
}
|
|
68
|
+
const requestOptions = {
|
|
69
|
+
url: `${this.resource}/beta/security/labels/retentionLabels`,
|
|
70
|
+
headers: {
|
|
71
|
+
accept: 'application/json;odata.metadata=none'
|
|
72
|
+
},
|
|
73
|
+
data: requestBody,
|
|
74
|
+
responseType: 'json'
|
|
75
|
+
};
|
|
76
|
+
try {
|
|
77
|
+
const response = yield request_1.default.post(requestOptions);
|
|
78
|
+
logger.log(response);
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
this.handleRejectedODataPromise(err);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
_PurviewRetentionLabelAddCommand_instances = new WeakSet(), _PurviewRetentionLabelAddCommand_initTelemetry = function _PurviewRetentionLabelAddCommand_initTelemetry() {
|
|
87
|
+
this.telemetry.push((args) => {
|
|
88
|
+
Object.assign(this.telemetryProperties, {
|
|
89
|
+
retentionTrigger: typeof args.options.retentionTrigger !== 'undefined',
|
|
90
|
+
defaultRecordBehavior: typeof args.options.defaultRecordBehavior !== 'undefined',
|
|
91
|
+
descriptionForUsers: typeof args.options.descriptionForUsers !== 'undefined',
|
|
92
|
+
descriptionForAdmins: typeof args.options.descriptionForAdmins !== 'undefined',
|
|
93
|
+
labelToBeApplied: typeof args.options.labelToBeApplied !== 'undefined'
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}, _PurviewRetentionLabelAddCommand_initOptions = function _PurviewRetentionLabelAddCommand_initOptions() {
|
|
97
|
+
this.options.unshift({
|
|
98
|
+
option: '-n, --displayName <displayName>'
|
|
99
|
+
}, {
|
|
100
|
+
option: '--behaviorDuringRetentionPeriod <behaviorDuringRetentionPeriod>',
|
|
101
|
+
autocomplete: ['doNotRetain', 'retain', 'retainAsRecord', 'retainAsRegulatoryRecord']
|
|
102
|
+
}, {
|
|
103
|
+
option: '--actionAfterRetentionPeriod <actionAfterRetentionPeriod>',
|
|
104
|
+
autocomplete: ['none', 'delete', 'startDispositionReview']
|
|
105
|
+
}, {
|
|
106
|
+
option: '--retentionDuration <retentionDuration>'
|
|
107
|
+
}, {
|
|
108
|
+
option: '-t, --retentionTrigger [retentionTrigger]',
|
|
109
|
+
autocomplete: ['dateLabeled', 'dateCreated', 'dateModified', 'dateOfEvent']
|
|
110
|
+
}, {
|
|
111
|
+
option: '--defaultRecordBehavior [defaultRecordBehavior]',
|
|
112
|
+
autocomplete: ['startLocked', 'startUnlocked']
|
|
113
|
+
}, {
|
|
114
|
+
option: '--descriptionForUsers [descriptionForUsers]'
|
|
115
|
+
}, {
|
|
116
|
+
option: '--descriptionForAdmins [descriptionForAdmins]'
|
|
117
|
+
}, {
|
|
118
|
+
option: '--labelToBeApplied [labelToBeApplied]'
|
|
119
|
+
});
|
|
120
|
+
}, _PurviewRetentionLabelAddCommand_initValidators = function _PurviewRetentionLabelAddCommand_initValidators() {
|
|
121
|
+
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
if (isNaN(args.options.retentionDuration)) {
|
|
123
|
+
return `Specified retentionDuration ${args.options.retentionDuration} is not a number`;
|
|
124
|
+
}
|
|
125
|
+
if (['doNotRetain', 'retain', 'retainAsRecord', 'retainAsRegulatoryRecord'].indexOf(args.options.behaviorDuringRetentionPeriod) === -1) {
|
|
126
|
+
return `${args.options.behaviorDuringRetentionPeriod} is not a valid behavior of a document with the label. Allowed values are doNotRetain|retain|retainAsRecord|retainAsRegulatoryRecord`;
|
|
127
|
+
}
|
|
128
|
+
if (['none', 'delete', 'startDispositionReview'].indexOf(args.options.actionAfterRetentionPeriod) === -1) {
|
|
129
|
+
return `${args.options.actionAfterRetentionPeriod} is not a valid action to take on a document with the label. Allowed values are none|delete|startDispositionReview`;
|
|
130
|
+
}
|
|
131
|
+
if (args.options.retentionTrigger &&
|
|
132
|
+
['dateLabeled', 'dateCreated', 'dateModified', 'dateOfEvent'].indexOf(args.options.retentionTrigger) === -1) {
|
|
133
|
+
return `${args.options.retentionTrigger} is not a valid action retention duration calculation. Allowed values are dateLabeled|dateCreated|dateModified|dateOfEvent`;
|
|
134
|
+
}
|
|
135
|
+
if (args.options.defaultRecordBehavior &&
|
|
136
|
+
['startLocked', 'startUnlocked'].indexOf(args.options.defaultRecordBehavior) === -1) {
|
|
137
|
+
return `${args.options.defaultRecordBehavior} is not a valid state of a record label. Allowed values are startLocked|startUnlocked`;
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
140
|
+
}));
|
|
141
|
+
};
|
|
142
|
+
module.exports = new PurviewRetentionLabelAddCommand();
|
|
143
|
+
//# sourceMappingURL=retentionlabel-add.js.map
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const prefix = 'purview';
|
|
4
4
|
exports.default = {
|
|
5
|
+
RETENTIONLABEL_ADD: `${prefix} retentionlabel add`,
|
|
5
6
|
RETENTIONLABEL_GET: `${prefix} retentionlabel get`,
|
|
6
7
|
RETENTIONLABEL_LIST: `${prefix} retentionlabel list`,
|
|
7
8
|
RETENTIONLABEL_REMOVE: `${prefix} retentionlabel remove`,
|
|
@@ -0,0 +1,116 @@
|
|
|
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 _SpoFileSharingLinkGetCommand_instances, _SpoFileSharingLinkGetCommand_initTelemetry, _SpoFileSharingLinkGetCommand_initOptions, _SpoFileSharingLinkGetCommand_initValidators, _SpoFileSharingLinkGetCommand_initOptionSets;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const request_1 = require("../../../../request");
|
|
19
|
+
const formatting_1 = require("../../../../utils/formatting");
|
|
20
|
+
const urlUtil_1 = require("../../../../utils/urlUtil");
|
|
21
|
+
const validation_1 = require("../../../../utils/validation");
|
|
22
|
+
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
23
|
+
const commands_1 = require("../../commands");
|
|
24
|
+
class SpoFileSharingLinkGetCommand extends SpoCommand_1.default {
|
|
25
|
+
get name() {
|
|
26
|
+
return commands_1.default.FILE_SHARINGLINK_GET;
|
|
27
|
+
}
|
|
28
|
+
get description() {
|
|
29
|
+
return 'Gets details about a specific sharing link of a file';
|
|
30
|
+
}
|
|
31
|
+
constructor() {
|
|
32
|
+
super();
|
|
33
|
+
_SpoFileSharingLinkGetCommand_instances.add(this);
|
|
34
|
+
__classPrivateFieldGet(this, _SpoFileSharingLinkGetCommand_instances, "m", _SpoFileSharingLinkGetCommand_initTelemetry).call(this);
|
|
35
|
+
__classPrivateFieldGet(this, _SpoFileSharingLinkGetCommand_instances, "m", _SpoFileSharingLinkGetCommand_initOptions).call(this);
|
|
36
|
+
__classPrivateFieldGet(this, _SpoFileSharingLinkGetCommand_instances, "m", _SpoFileSharingLinkGetCommand_initValidators).call(this);
|
|
37
|
+
__classPrivateFieldGet(this, _SpoFileSharingLinkGetCommand_instances, "m", _SpoFileSharingLinkGetCommand_initOptionSets).call(this);
|
|
38
|
+
}
|
|
39
|
+
commandAction(logger, args) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
if (this.verbose) {
|
|
42
|
+
logger.logToStderr(`Retrieving sharing link for file ${args.options.fileUrl || args.options.fileId} with id ${args.options.id}...`);
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const fileDetails = yield this.getNeededFileInformation(args);
|
|
46
|
+
const requestOptions = {
|
|
47
|
+
url: `https://graph.microsoft.com/v1.0/sites/${fileDetails.SiteId}/drives/${fileDetails.VroomDriveID}/items/${fileDetails.VroomItemID}/permissions/${args.options.id}`,
|
|
48
|
+
headers: {
|
|
49
|
+
accept: 'application/json;odata.metadata=none'
|
|
50
|
+
},
|
|
51
|
+
responseType: 'json'
|
|
52
|
+
};
|
|
53
|
+
const res = yield request_1.default.get(requestOptions);
|
|
54
|
+
logger.log(res);
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
this.handleRejectedODataJsonPromise(err);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
getNeededFileInformation(args) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
let requestUrl = `${args.options.webUrl}/_api/web/`;
|
|
64
|
+
if (args.options.fileUrl) {
|
|
65
|
+
const fileServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.fileUrl);
|
|
66
|
+
requestUrl += `GetFileByServerRelativePath(decodedUrl='${formatting_1.formatting.encodeQueryParameter(fileServerRelativeUrl)}')`;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
requestUrl += `GetFileById('${args.options.fileId}')`;
|
|
70
|
+
}
|
|
71
|
+
requestUrl += '?$select=SiteId,VroomItemId,VroomDriveId';
|
|
72
|
+
const requestOptions = {
|
|
73
|
+
url: requestUrl,
|
|
74
|
+
headers: {
|
|
75
|
+
accept: 'application/json;odata=nometadata'
|
|
76
|
+
},
|
|
77
|
+
responseType: 'json'
|
|
78
|
+
};
|
|
79
|
+
const res = yield request_1.default.get(requestOptions);
|
|
80
|
+
return res;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
_SpoFileSharingLinkGetCommand_instances = new WeakSet(), _SpoFileSharingLinkGetCommand_initTelemetry = function _SpoFileSharingLinkGetCommand_initTelemetry() {
|
|
85
|
+
this.telemetry.push((args) => {
|
|
86
|
+
Object.assign(this.telemetryProperties, {
|
|
87
|
+
fileUrl: typeof args.options.fileUrl !== 'undefined',
|
|
88
|
+
fileId: typeof args.options.fileId !== 'undefined'
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}, _SpoFileSharingLinkGetCommand_initOptions = function _SpoFileSharingLinkGetCommand_initOptions() {
|
|
92
|
+
this.options.unshift({
|
|
93
|
+
option: '-u, --webUrl <webUrl>'
|
|
94
|
+
}, {
|
|
95
|
+
option: '--fileUrl [fileUrl]'
|
|
96
|
+
}, {
|
|
97
|
+
option: '--fileId [fileId]'
|
|
98
|
+
}, {
|
|
99
|
+
option: '-i, --id <id>'
|
|
100
|
+
});
|
|
101
|
+
}, _SpoFileSharingLinkGetCommand_initValidators = function _SpoFileSharingLinkGetCommand_initValidators() {
|
|
102
|
+
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
|
|
104
|
+
if (isValidSharePointUrl !== true) {
|
|
105
|
+
return isValidSharePointUrl;
|
|
106
|
+
}
|
|
107
|
+
if (args.options.fileId && !validation_1.validation.isValidGuid(args.options.fileId)) {
|
|
108
|
+
return `${args.options.fileId} is not a valid GUID`;
|
|
109
|
+
}
|
|
110
|
+
return true;
|
|
111
|
+
}));
|
|
112
|
+
}, _SpoFileSharingLinkGetCommand_initOptionSets = function _SpoFileSharingLinkGetCommand_initOptionSets() {
|
|
113
|
+
this.optionSets.push({ options: ['fileUrl', 'fileId'] });
|
|
114
|
+
};
|
|
115
|
+
module.exports = new SpoFileSharingLinkGetCommand();
|
|
116
|
+
//# sourceMappingURL=file-sharinglink-get.js.map
|
|
@@ -29,7 +29,7 @@ class SpoFileSharingLinkListCommand extends SpoCommand_1.default {
|
|
|
29
29
|
return 'Lists all the sharing links of a specific file';
|
|
30
30
|
}
|
|
31
31
|
defaultProperties() {
|
|
32
|
-
return ['id', 'roles', 'link'];
|
|
32
|
+
return ['id', 'scope', 'roles', 'link'];
|
|
33
33
|
}
|
|
34
34
|
constructor() {
|
|
35
35
|
super();
|
|
@@ -46,7 +46,11 @@ class SpoFileSharingLinkListCommand extends SpoCommand_1.default {
|
|
|
46
46
|
}
|
|
47
47
|
try {
|
|
48
48
|
const fileDetails = yield this.getFileDetails(args.options.webUrl, args.options.fileId, args.options.fileUrl);
|
|
49
|
-
|
|
49
|
+
let url = `https://graph.microsoft.com/v1.0/sites/${fileDetails.SiteId}/drives/${fileDetails.VroomDriveID}/items/${fileDetails.VroomItemID}/permissions?$filter=Link ne null`;
|
|
50
|
+
if (args.options.scope) {
|
|
51
|
+
url += ` and Link/Scope eq '${args.options.scope}'`;
|
|
52
|
+
}
|
|
53
|
+
const sharingLinks = yield odata_1.odata.getAllItems(url);
|
|
50
54
|
if (!args.options.output || args.options.output === 'json' || args.options.output === 'md') {
|
|
51
55
|
logger.log(sharingLinks);
|
|
52
56
|
}
|
|
@@ -56,7 +60,8 @@ class SpoFileSharingLinkListCommand extends SpoCommand_1.default {
|
|
|
56
60
|
return {
|
|
57
61
|
id: i.id,
|
|
58
62
|
roles: i.roles.join(','),
|
|
59
|
-
link: i.link.webUrl
|
|
63
|
+
link: i.link.webUrl,
|
|
64
|
+
scope: i.link.scope
|
|
60
65
|
};
|
|
61
66
|
}));
|
|
62
67
|
}
|
|
@@ -91,7 +96,8 @@ _SpoFileSharingLinkListCommand_instances = new WeakSet(), _SpoFileSharingLinkLis
|
|
|
91
96
|
this.telemetry.push((args) => {
|
|
92
97
|
Object.assign(this.telemetryProperties, {
|
|
93
98
|
fileId: typeof args.options.fileId !== 'undefined',
|
|
94
|
-
fileUrl: typeof args.options.fileUrl !== 'undefined'
|
|
99
|
+
fileUrl: typeof args.options.fileUrl !== 'undefined',
|
|
100
|
+
scope: typeof args.options.scope !== 'undefined'
|
|
95
101
|
});
|
|
96
102
|
});
|
|
97
103
|
}, _SpoFileSharingLinkListCommand_initOptions = function _SpoFileSharingLinkListCommand_initOptions() {
|
|
@@ -101,6 +107,9 @@ _SpoFileSharingLinkListCommand_instances = new WeakSet(), _SpoFileSharingLinkLis
|
|
|
101
107
|
option: '-i, --fileId [fileId]'
|
|
102
108
|
}, {
|
|
103
109
|
option: '-f, --fileUrl [fileUrl]'
|
|
110
|
+
}, {
|
|
111
|
+
option: '--scope [scope]',
|
|
112
|
+
autocomplete: SpoFileSharingLinkListCommand.scope
|
|
104
113
|
});
|
|
105
114
|
}, _SpoFileSharingLinkListCommand_initValidators = function _SpoFileSharingLinkListCommand_initValidators() {
|
|
106
115
|
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -111,10 +120,14 @@ _SpoFileSharingLinkListCommand_instances = new WeakSet(), _SpoFileSharingLinkLis
|
|
|
111
120
|
if (args.options.fileId && !validation_1.validation.isValidGuid(args.options.fileId)) {
|
|
112
121
|
return `${args.options.fileId} is not a valid GUID`;
|
|
113
122
|
}
|
|
123
|
+
if (args.options.scope && SpoFileSharingLinkListCommand.scope.indexOf(args.options.scope) === -1) {
|
|
124
|
+
return `'${args.options.scope}' is not a valid scope. Allowed values are: ${SpoFileSharingLinkListCommand.scope.join(',')}`;
|
|
125
|
+
}
|
|
114
126
|
return true;
|
|
115
127
|
}));
|
|
116
128
|
}, _SpoFileSharingLinkListCommand_initOptionSets = function _SpoFileSharingLinkListCommand_initOptionSets() {
|
|
117
129
|
this.optionSets.push({ options: ['fileId', 'fileUrl'] });
|
|
118
130
|
};
|
|
131
|
+
SpoFileSharingLinkListCommand.scope = ['anonymous', 'users', 'organization'];
|
|
119
132
|
module.exports = new SpoFileSharingLinkListCommand();
|
|
120
133
|
//# sourceMappingURL=file-sharinglink-list.js.map
|
|
@@ -0,0 +1,135 @@
|
|
|
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 _SpoFileSharingLinkRemoveCommand_instances, _SpoFileSharingLinkRemoveCommand_initTelemetry, _SpoFileSharingLinkRemoveCommand_initOptions, _SpoFileSharingLinkRemoveCommand_initValidators, _SpoFileSharingLinkRemoveCommand_initOptionSets;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const Cli_1 = require("../../../../cli/Cli");
|
|
19
|
+
const request_1 = require("../../../../request");
|
|
20
|
+
const formatting_1 = require("../../../../utils/formatting");
|
|
21
|
+
const urlUtil_1 = require("../../../../utils/urlUtil");
|
|
22
|
+
const validation_1 = require("../../../../utils/validation");
|
|
23
|
+
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
24
|
+
const commands_1 = require("../../commands");
|
|
25
|
+
class SpoFileSharingLinkRemoveCommand extends SpoCommand_1.default {
|
|
26
|
+
get name() {
|
|
27
|
+
return commands_1.default.FILE_SHARINGLINK_REMOVE;
|
|
28
|
+
}
|
|
29
|
+
get description() {
|
|
30
|
+
return 'Removes a specific sharing link of a file';
|
|
31
|
+
}
|
|
32
|
+
constructor() {
|
|
33
|
+
super();
|
|
34
|
+
_SpoFileSharingLinkRemoveCommand_instances.add(this);
|
|
35
|
+
__classPrivateFieldGet(this, _SpoFileSharingLinkRemoveCommand_instances, "m", _SpoFileSharingLinkRemoveCommand_initTelemetry).call(this);
|
|
36
|
+
__classPrivateFieldGet(this, _SpoFileSharingLinkRemoveCommand_instances, "m", _SpoFileSharingLinkRemoveCommand_initOptions).call(this);
|
|
37
|
+
__classPrivateFieldGet(this, _SpoFileSharingLinkRemoveCommand_instances, "m", _SpoFileSharingLinkRemoveCommand_initValidators).call(this);
|
|
38
|
+
__classPrivateFieldGet(this, _SpoFileSharingLinkRemoveCommand_instances, "m", _SpoFileSharingLinkRemoveCommand_initOptionSets).call(this);
|
|
39
|
+
}
|
|
40
|
+
commandAction(logger, args) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const removeSharingLink = () => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
try {
|
|
44
|
+
if (this.verbose) {
|
|
45
|
+
logger.logToStderr(`Removing sharing link of file ${args.options.fileUrl || args.options.fileId} with id ${args.options.id}...`);
|
|
46
|
+
}
|
|
47
|
+
const fileDetails = yield this.getNeededFileInformation(args);
|
|
48
|
+
const requestOptions = {
|
|
49
|
+
url: `https://graph.microsoft.com/v1.0/sites/${fileDetails.SiteId}/drives/${fileDetails.VroomDriveID}/items/${fileDetails.VroomItemID}/permissions/${args.options.id}`,
|
|
50
|
+
headers: {
|
|
51
|
+
accept: 'application/json;odata.metadata=none'
|
|
52
|
+
},
|
|
53
|
+
responseType: 'json'
|
|
54
|
+
};
|
|
55
|
+
yield request_1.default.delete(requestOptions);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
this.handleRejectedODataJsonPromise(err);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
if (args.options.confirm) {
|
|
62
|
+
yield removeSharingLink();
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
const result = yield Cli_1.Cli.prompt({
|
|
66
|
+
type: 'confirm',
|
|
67
|
+
name: 'continue',
|
|
68
|
+
default: false,
|
|
69
|
+
message: `Are you sure you want to remove sharing link ${args.options.id} of file ${args.options.fileUrl || args.options.fileId}?`
|
|
70
|
+
});
|
|
71
|
+
if (result.continue) {
|
|
72
|
+
yield removeSharingLink();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
getNeededFileInformation(args) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
let requestUrl = `${args.options.webUrl}/_api/web/`;
|
|
80
|
+
if (args.options.fileUrl) {
|
|
81
|
+
const fileServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.fileUrl);
|
|
82
|
+
requestUrl += `GetFileByServerRelativePath(decodedUrl='${formatting_1.formatting.encodeQueryParameter(fileServerRelativeUrl)}')`;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
requestUrl += `GetFileById('${args.options.fileId}')`;
|
|
86
|
+
}
|
|
87
|
+
requestUrl += '?$select=SiteId,VroomItemId,VroomDriveId';
|
|
88
|
+
const requestOptions = {
|
|
89
|
+
url: requestUrl,
|
|
90
|
+
headers: {
|
|
91
|
+
accept: 'application/json;odata=nometadata'
|
|
92
|
+
},
|
|
93
|
+
responseType: 'json'
|
|
94
|
+
};
|
|
95
|
+
const res = yield request_1.default.get(requestOptions);
|
|
96
|
+
return res;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
_SpoFileSharingLinkRemoveCommand_instances = new WeakSet(), _SpoFileSharingLinkRemoveCommand_initTelemetry = function _SpoFileSharingLinkRemoveCommand_initTelemetry() {
|
|
101
|
+
this.telemetry.push((args) => {
|
|
102
|
+
Object.assign(this.telemetryProperties, {
|
|
103
|
+
fileUrl: typeof args.options.fileUrl !== 'undefined',
|
|
104
|
+
fileId: typeof args.options.fileId !== 'undefined',
|
|
105
|
+
confirm: !!args.options.confirm
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}, _SpoFileSharingLinkRemoveCommand_initOptions = function _SpoFileSharingLinkRemoveCommand_initOptions() {
|
|
109
|
+
this.options.unshift({
|
|
110
|
+
option: '-u, --webUrl <webUrl>'
|
|
111
|
+
}, {
|
|
112
|
+
option: '--fileUrl [fileUrl]'
|
|
113
|
+
}, {
|
|
114
|
+
option: '--fileId [fileId]'
|
|
115
|
+
}, {
|
|
116
|
+
option: '-i, --id <id>'
|
|
117
|
+
}, {
|
|
118
|
+
option: '--confirm'
|
|
119
|
+
});
|
|
120
|
+
}, _SpoFileSharingLinkRemoveCommand_initValidators = function _SpoFileSharingLinkRemoveCommand_initValidators() {
|
|
121
|
+
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
|
|
123
|
+
if (isValidSharePointUrl !== true) {
|
|
124
|
+
return isValidSharePointUrl;
|
|
125
|
+
}
|
|
126
|
+
if (args.options.fileId && !validation_1.validation.isValidGuid(args.options.fileId)) {
|
|
127
|
+
return `${args.options.fileId} is not a valid GUID`;
|
|
128
|
+
}
|
|
129
|
+
return true;
|
|
130
|
+
}));
|
|
131
|
+
}, _SpoFileSharingLinkRemoveCommand_initOptionSets = function _SpoFileSharingLinkRemoveCommand_initOptionSets() {
|
|
132
|
+
this.optionSets.push({ options: ['fileUrl', 'fileId'] });
|
|
133
|
+
};
|
|
134
|
+
module.exports = new SpoFileSharingLinkRemoveCommand();
|
|
135
|
+
//# sourceMappingURL=file-sharinglink-remove.js.map
|