@pnp/cli-microsoft365 6.2.0-beta.d5442a1 → 6.2.0-beta.ed6bb7b

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 (57) hide show
  1. package/dist/m365/onenote/commands/page/page-list.js +137 -0
  2. package/dist/m365/onenote/commands.js +2 -1
  3. package/dist/m365/planner/commands/bucket/bucket-add.js +0 -6
  4. package/dist/m365/planner/commands/bucket/bucket-get.js +0 -6
  5. package/dist/m365/planner/commands/bucket/bucket-list.js +0 -6
  6. package/dist/m365/planner/commands/bucket/bucket-remove.js +0 -6
  7. package/dist/m365/planner/commands/bucket/bucket-set.js +0 -6
  8. package/dist/m365/planner/commands/plan/plan-add.js +0 -6
  9. package/dist/m365/planner/commands/plan/plan-get.js +0 -6
  10. package/dist/m365/planner/commands/plan/plan-list.js +0 -6
  11. package/dist/m365/planner/commands/plan/plan-remove.js +0 -6
  12. package/dist/m365/planner/commands/plan/plan-set.js +0 -6
  13. package/dist/m365/planner/commands/task/task-add.js +0 -6
  14. package/dist/m365/planner/commands/task/task-checklistitem-add.js +0 -6
  15. package/dist/m365/planner/commands/task/task-checklistitem-list.js +0 -6
  16. package/dist/m365/planner/commands/task/task-get.js +0 -6
  17. package/dist/m365/planner/commands/task/task-list.js +0 -6
  18. package/dist/m365/planner/commands/task/task-reference-list.js +0 -6
  19. package/dist/m365/planner/commands/task/task-set.js +0 -6
  20. package/dist/m365/pp/commands/aibuildermodel/aibuildermodel-get.js +110 -0
  21. package/dist/m365/pp/commands/aibuildermodel/aibuildermodel-remove.js +130 -0
  22. package/dist/m365/pp/commands.js +2 -0
  23. package/dist/m365/purview/commands/retentionlabel/retentionlabel-add.js +143 -0
  24. package/dist/m365/purview/commands.js +1 -0
  25. package/dist/m365/spo/commands/file/file-sharinglink-get.js +116 -0
  26. package/dist/m365/spo/commands/file/file-sharinglink-list.js +17 -4
  27. package/dist/m365/spo/commands/file/file-sharinglink-remove.js +135 -0
  28. package/dist/m365/spo/commands/group/group-member-add.js +33 -6
  29. package/dist/m365/spo/commands/list/list-add.js +3 -0
  30. package/dist/m365/spo/commands/list/list-set.js +3 -0
  31. package/dist/m365/spo/commands/listitem/listitem-list.js +1 -1
  32. package/dist/m365/spo/commands/term/term-list.js +99 -29
  33. package/dist/m365/spo/commands.js +2 -0
  34. package/dist/m365/teams/commands/message/message-send.js +81 -0
  35. package/dist/m365/teams/commands.js +1 -0
  36. package/docs/docs/cmd/onenote/page/page-list.md +140 -0
  37. package/docs/docs/cmd/pp/aibuildermodel/aibuildermodel-get.md +99 -0
  38. package/docs/docs/cmd/pp/aibuildermodel/aibuildermodel-remove.md +53 -0
  39. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-add.md +128 -0
  40. package/docs/docs/cmd/spo/cdn/cdn-get.md +1 -1
  41. package/docs/docs/cmd/spo/cdn/cdn-origin-add.md +1 -1
  42. package/docs/docs/cmd/spo/cdn/cdn-origin-list.md +1 -1
  43. package/docs/docs/cmd/spo/cdn/cdn-origin-remove.md +1 -1
  44. package/docs/docs/cmd/spo/cdn/cdn-policy-list.md +1 -1
  45. package/docs/docs/cmd/spo/cdn/cdn-policy-set.md +1 -1
  46. package/docs/docs/cmd/spo/cdn/cdn-set.md +1 -1
  47. package/docs/docs/cmd/spo/file/file-sharinglink-get.md +107 -0
  48. package/docs/docs/cmd/spo/file/file-sharinglink-list.md +16 -7
  49. package/docs/docs/cmd/spo/file/file-sharinglink-remove.md +52 -0
  50. package/docs/docs/cmd/spo/group/group-member-add.md +22 -4
  51. package/docs/docs/cmd/spo/list/list-add.md +3 -9
  52. package/docs/docs/cmd/spo/list/list-set.md +3 -3
  53. package/docs/docs/cmd/spo/listitem/listitem-get.md +11 -12
  54. package/docs/docs/cmd/spo/listitem/listitem-list.md +5 -5
  55. package/docs/docs/cmd/spo/term/term-list.md +138 -0
  56. package/docs/docs/cmd/teams/message/message-send.md +119 -0
  57. package/package.json +1 -1
@@ -0,0 +1,130 @@
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 _PpAiBuilderModelRemoveCommand_instances, _PpAiBuilderModelRemoveCommand_initTelemetry, _PpAiBuilderModelRemoveCommand_initOptions, _PpAiBuilderModelRemoveCommand_initOptionSets, _PpAiBuilderModelRemoveCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const powerPlatform_1 = require("../../../../utils/powerPlatform");
19
+ const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
20
+ const commands_1 = require("../../commands");
21
+ const request_1 = require("../../../../request");
22
+ const validation_1 = require("../../../../utils/validation");
23
+ const Cli_1 = require("../../../../cli/Cli");
24
+ const PpAiBuilderModelGetCommand = require("./aibuildermodel-get");
25
+ class PpAiBuilderModelRemoveCommand extends PowerPlatformCommand_1.default {
26
+ get name() {
27
+ return commands_1.default.AIBUILDERMODEL_REMOVE;
28
+ }
29
+ get description() {
30
+ return 'Removes an AI builder model in the specified Power Platform environment.';
31
+ }
32
+ constructor() {
33
+ super();
34
+ _PpAiBuilderModelRemoveCommand_instances.add(this);
35
+ __classPrivateFieldGet(this, _PpAiBuilderModelRemoveCommand_instances, "m", _PpAiBuilderModelRemoveCommand_initTelemetry).call(this);
36
+ __classPrivateFieldGet(this, _PpAiBuilderModelRemoveCommand_instances, "m", _PpAiBuilderModelRemoveCommand_initOptions).call(this);
37
+ __classPrivateFieldGet(this, _PpAiBuilderModelRemoveCommand_instances, "m", _PpAiBuilderModelRemoveCommand_initValidators).call(this);
38
+ __classPrivateFieldGet(this, _PpAiBuilderModelRemoveCommand_instances, "m", _PpAiBuilderModelRemoveCommand_initOptionSets).call(this);
39
+ }
40
+ commandAction(logger, args) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ if (this.verbose) {
43
+ logger.logToStderr(`Removing AI builder model '${args.options.id || args.options.name}'...`);
44
+ }
45
+ if (args.options.confirm) {
46
+ yield this.deleteAiBuilderModel(args);
47
+ }
48
+ else {
49
+ const result = yield Cli_1.Cli.prompt({
50
+ type: 'confirm',
51
+ name: 'continue',
52
+ default: false,
53
+ message: `Are you sure you want to remove AI builder model '${args.options.id || args.options.name}'?`
54
+ });
55
+ if (result.continue) {
56
+ yield this.deleteAiBuilderModel(args);
57
+ }
58
+ }
59
+ });
60
+ }
61
+ getAiBuilderModelId(args) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ if (args.options.id) {
64
+ return args.options.id;
65
+ }
66
+ const options = {
67
+ environment: args.options.environment,
68
+ name: args.options.name,
69
+ output: 'json',
70
+ debug: this.debug,
71
+ verbose: this.verbose
72
+ };
73
+ const output = yield Cli_1.Cli.executeCommandWithOutput(PpAiBuilderModelGetCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
74
+ const getAiBuilderModelOutput = JSON.parse(output.stdout);
75
+ return getAiBuilderModelOutput.msdyn_aimodelid;
76
+ });
77
+ }
78
+ deleteAiBuilderModel(args) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ try {
81
+ const dynamicsApiUrl = yield powerPlatform_1.powerPlatform.getDynamicsInstanceApiUrl(args.options.environment, args.options.asAdmin);
82
+ const aiBuilderModelId = yield this.getAiBuilderModelId(args);
83
+ const requestOptions = {
84
+ url: `${dynamicsApiUrl}/api/data/v9.1/msdyn_aimodels(${aiBuilderModelId})`,
85
+ headers: {
86
+ accept: 'application/json;odata.metadata=none'
87
+ },
88
+ responseType: 'json'
89
+ };
90
+ yield request_1.default.delete(requestOptions);
91
+ }
92
+ catch (err) {
93
+ this.handleRejectedODataJsonPromise(err);
94
+ }
95
+ });
96
+ }
97
+ }
98
+ _PpAiBuilderModelRemoveCommand_instances = new WeakSet(), _PpAiBuilderModelRemoveCommand_initTelemetry = function _PpAiBuilderModelRemoveCommand_initTelemetry() {
99
+ this.telemetry.push((args) => {
100
+ Object.assign(this.telemetryProperties, {
101
+ id: typeof args.options.id !== 'undefined',
102
+ name: typeof args.options.name !== 'undefined',
103
+ asAdmin: !!args.options.asAdmin,
104
+ confirm: !!args.options.confirm
105
+ });
106
+ });
107
+ }, _PpAiBuilderModelRemoveCommand_initOptions = function _PpAiBuilderModelRemoveCommand_initOptions() {
108
+ this.options.unshift({
109
+ option: '-e, --environment <environment>'
110
+ }, {
111
+ option: '-i, --id [id]'
112
+ }, {
113
+ option: '-n, --name [name]'
114
+ }, {
115
+ option: '--asAdmin'
116
+ }, {
117
+ option: '--confirm'
118
+ });
119
+ }, _PpAiBuilderModelRemoveCommand_initOptionSets = function _PpAiBuilderModelRemoveCommand_initOptionSets() {
120
+ this.optionSets.push({ options: ['id', 'name'] });
121
+ }, _PpAiBuilderModelRemoveCommand_initValidators = function _PpAiBuilderModelRemoveCommand_initValidators() {
122
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
123
+ if (args.options.id && !validation_1.validation.isValidGuid(args.options.id)) {
124
+ return `${args.options.id} is not a valid GUID`;
125
+ }
126
+ return true;
127
+ }));
128
+ };
129
+ module.exports = new PpAiBuilderModelRemoveCommand();
130
+ //# sourceMappingURL=aibuildermodel-remove.js.map
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prefix = 'pp';
4
4
  exports.default = {
5
+ AIBUILDERMODEL_GET: `${prefix} aibuildermodel get`,
5
6
  AIBUILDERMODEL_LIST: `${prefix} aibuildermodel list`,
7
+ AIBUILDERMODEL_REMOVE: `${prefix} aibuildermodel remove`,
6
8
  CARD_CLONE: `${prefix} card clone`,
7
9
  CARD_GET: `${prefix} card get`,
8
10
  CARD_LIST: `${prefix} card list`,
@@ -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
- const sharingLinks = yield odata_1.odata.getAllItems(`https://graph.microsoft.com/v1.0/sites/${fileDetails.SiteId}/drives/${fileDetails.VroomDriveID}/items/${fileDetails.VroomItemID}/permissions?$filter=Link ne null`);
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