@pnp/cli-microsoft365 6.2.0-beta.725ebd5 → 6.2.0-beta.97d58e0

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 (79) hide show
  1. package/dist/m365/context/commands/option/option-remove.js +105 -0
  2. package/dist/m365/context/commands/option/option-set.js +84 -0
  3. package/dist/m365/context/commands.js +2 -0
  4. package/dist/m365/onenote/commands/page/page-list.js +137 -0
  5. package/dist/m365/onenote/commands.js +2 -1
  6. package/dist/m365/planner/commands/bucket/bucket-add.js +0 -6
  7. package/dist/m365/planner/commands/bucket/bucket-get.js +0 -6
  8. package/dist/m365/planner/commands/bucket/bucket-list.js +0 -6
  9. package/dist/m365/planner/commands/bucket/bucket-remove.js +0 -6
  10. package/dist/m365/planner/commands/bucket/bucket-set.js +0 -6
  11. package/dist/m365/planner/commands/plan/plan-add.js +0 -6
  12. package/dist/m365/planner/commands/plan/plan-get.js +0 -6
  13. package/dist/m365/planner/commands/plan/plan-list.js +0 -6
  14. package/dist/m365/planner/commands/plan/plan-remove.js +0 -6
  15. package/dist/m365/planner/commands/plan/plan-set.js +0 -6
  16. package/dist/m365/planner/commands/task/task-add.js +0 -6
  17. package/dist/m365/planner/commands/task/task-checklistitem-add.js +0 -6
  18. package/dist/m365/planner/commands/task/task-checklistitem-list.js +0 -6
  19. package/dist/m365/planner/commands/task/task-get.js +0 -6
  20. package/dist/m365/planner/commands/task/task-list.js +0 -6
  21. package/dist/m365/planner/commands/task/task-reference-list.js +0 -6
  22. package/dist/m365/planner/commands/task/task-set.js +0 -6
  23. package/dist/m365/pp/commands/aibuildermodel/aibuildermodel-get.js +110 -0
  24. package/dist/m365/pp/commands/aibuildermodel/aibuildermodel-remove.js +130 -0
  25. package/dist/m365/pp/commands/solution/solution-publish.js +156 -0
  26. package/dist/m365/pp/commands.js +3 -0
  27. package/dist/m365/purview/commands/retentionlabel/retentionlabel-add.js +143 -0
  28. package/dist/m365/purview/commands.js +1 -0
  29. package/dist/m365/spo/commands/file/file-retentionlabel-ensure.js +121 -0
  30. package/dist/m365/spo/commands/file/file-retentionlabel-remove.js +141 -0
  31. package/dist/m365/spo/commands/file/file-sharinglink-add.js +141 -0
  32. package/dist/m365/spo/commands/file/file-sharinglink-get.js +116 -0
  33. package/dist/m365/spo/commands/file/file-sharinglink-list.js +19 -6
  34. package/dist/m365/spo/commands/file/file-sharinglink-remove.js +135 -0
  35. package/dist/m365/spo/commands/folder/folder-retentionlabel-ensure.js +138 -0
  36. package/dist/m365/spo/commands/folder/folder-retentionlabel-remove.js +157 -0
  37. package/dist/m365/spo/commands/group/group-member-add.js +33 -6
  38. package/dist/m365/spo/commands/list/list-add.js +3 -0
  39. package/dist/m365/spo/commands/list/list-retentionlabel-remove.js +146 -0
  40. package/dist/m365/spo/commands/list/list-set.js +3 -0
  41. package/dist/m365/spo/commands/listitem/listitem-list.js +1 -1
  42. package/dist/m365/spo/commands/listitem/listitem-retentionlabel-remove.js +2 -2
  43. package/dist/m365/spo/commands/term/term-list.js +99 -29
  44. package/dist/m365/spo/commands.js +8 -0
  45. package/dist/m365/teams/commands/message/message-send.js +81 -0
  46. package/dist/m365/teams/commands.js +1 -0
  47. package/dist/utils/formatting.js +22 -0
  48. package/docs/docs/cmd/aad/app/app-remove.md +11 -7
  49. package/docs/docs/cmd/context/option/option-remove.md +37 -0
  50. package/docs/docs/cmd/context/option/option-set.md +31 -0
  51. package/docs/docs/cmd/onenote/page/page-list.md +140 -0
  52. package/docs/docs/cmd/pp/aibuildermodel/aibuildermodel-get.md +99 -0
  53. package/docs/docs/cmd/pp/aibuildermodel/aibuildermodel-remove.md +53 -0
  54. package/docs/docs/cmd/pp/solution/solution-publish.md +52 -0
  55. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-add.md +128 -0
  56. package/docs/docs/cmd/spo/cdn/cdn-get.md +1 -1
  57. package/docs/docs/cmd/spo/cdn/cdn-origin-add.md +1 -1
  58. package/docs/docs/cmd/spo/cdn/cdn-origin-list.md +1 -1
  59. package/docs/docs/cmd/spo/cdn/cdn-origin-remove.md +1 -1
  60. package/docs/docs/cmd/spo/cdn/cdn-policy-list.md +1 -1
  61. package/docs/docs/cmd/spo/cdn/cdn-policy-set.md +1 -1
  62. package/docs/docs/cmd/spo/cdn/cdn-set.md +1 -1
  63. package/docs/docs/cmd/spo/file/file-retentionlabel-ensure.md +47 -0
  64. package/docs/docs/cmd/spo/file/file-retentionlabel-remove.md +43 -0
  65. package/docs/docs/cmd/spo/file/file-sharinglink-add.md +89 -0
  66. package/docs/docs/cmd/spo/file/file-sharinglink-get.md +107 -0
  67. package/docs/docs/cmd/spo/file/file-sharinglink-list.md +16 -7
  68. package/docs/docs/cmd/spo/file/file-sharinglink-remove.md +52 -0
  69. package/docs/docs/cmd/spo/folder/folder-retentionlabel-ensure.md +47 -0
  70. package/docs/docs/cmd/spo/folder/folder-retentionlabel-remove.md +43 -0
  71. package/docs/docs/cmd/spo/group/group-member-add.md +22 -4
  72. package/docs/docs/cmd/spo/list/list-add.md +3 -9
  73. package/docs/docs/cmd/spo/list/list-retentionlabel-remove.md +52 -0
  74. package/docs/docs/cmd/spo/list/list-set.md +3 -3
  75. package/docs/docs/cmd/spo/listitem/listitem-get.md +11 -12
  76. package/docs/docs/cmd/spo/listitem/listitem-list.md +5 -5
  77. package/docs/docs/cmd/spo/term/term-list.md +138 -0
  78. package/docs/docs/cmd/teams/message/message-send.md +119 -0
  79. package/package.json +1 -1
@@ -0,0 +1,121 @@
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 _SpoFileRetentionLabelEnsureCommand_instances, _SpoFileRetentionLabelEnsureCommand_initTelemetry, _SpoFileRetentionLabelEnsureCommand_initOptions, _SpoFileRetentionLabelEnsureCommand_initValidators, _SpoFileRetentionLabelEnsureCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
19
+ const request_1 = require("../../../../request");
20
+ const validation_1 = require("../../../../utils/validation");
21
+ const SpoCommand_1 = require("../../../base/SpoCommand");
22
+ const commands_1 = require("../../commands");
23
+ const SpoListItemRetentionLabelEnsureCommand = require("../listitem/listitem-retentionlabel-ensure");
24
+ const formatting_1 = require("../../../../utils/formatting");
25
+ const urlUtil_1 = require("../../../../utils/urlUtil");
26
+ class SpoFileRetentionLabelEnsureCommand extends SpoCommand_1.default {
27
+ get name() {
28
+ return commands_1.default.FILE_RETENTIONLABEL_ENSURE;
29
+ }
30
+ get description() {
31
+ return 'Apply a retention label to a file';
32
+ }
33
+ constructor() {
34
+ super();
35
+ _SpoFileRetentionLabelEnsureCommand_instances.add(this);
36
+ __classPrivateFieldGet(this, _SpoFileRetentionLabelEnsureCommand_instances, "m", _SpoFileRetentionLabelEnsureCommand_initTelemetry).call(this);
37
+ __classPrivateFieldGet(this, _SpoFileRetentionLabelEnsureCommand_instances, "m", _SpoFileRetentionLabelEnsureCommand_initOptions).call(this);
38
+ __classPrivateFieldGet(this, _SpoFileRetentionLabelEnsureCommand_instances, "m", _SpoFileRetentionLabelEnsureCommand_initValidators).call(this);
39
+ __classPrivateFieldGet(this, _SpoFileRetentionLabelEnsureCommand_instances, "m", _SpoFileRetentionLabelEnsureCommand_initOptionSets).call(this);
40
+ }
41
+ commandAction(logger, args) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ try {
44
+ const fileProperties = yield this.getFileProperties(logger, args);
45
+ const options = {
46
+ webUrl: args.options.webUrl,
47
+ listId: fileProperties.ListItemAllFields.ParentList.Id,
48
+ listItemId: fileProperties.ListItemAllFields.Id,
49
+ name: args.options.name,
50
+ output: 'json',
51
+ debug: this.debug,
52
+ verbose: this.verbose
53
+ };
54
+ const spoListItemRetentionLabelEnsureCommandOutput = yield Cli_1.Cli.executeCommandWithOutput(SpoListItemRetentionLabelEnsureCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
55
+ if (this.verbose) {
56
+ logger.logToStderr(spoListItemRetentionLabelEnsureCommandOutput.stderr);
57
+ }
58
+ }
59
+ catch (err) {
60
+ this.handleRejectedODataJsonPromise(err);
61
+ }
62
+ });
63
+ }
64
+ getFileProperties(logger, args) {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ if (this.verbose) {
67
+ logger.logToStderr(`Retrieving list and item information for file '${args.options.fileId || args.options.fileUrl}' in site at ${args.options.webUrl}...`);
68
+ }
69
+ let requestUrl = `${args.options.webUrl}/_api/web/`;
70
+ if (args.options.fileId) {
71
+ requestUrl += `GetFileById('${args.options.fileId}')`;
72
+ }
73
+ else {
74
+ const serverRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.fileUrl);
75
+ requestUrl += `GetFileByServerRelativeUrl('${formatting_1.formatting.encodeQueryParameter(serverRelativeUrl)}')`;
76
+ }
77
+ const requestOptions = {
78
+ url: `${requestUrl}?$expand=ListItemAllFields,ListItemAllFields/ParentList&$select=ServerRelativeUrl,ListItemAllFields/ParentList/Id,ListItemAllFields/Id`,
79
+ headers: {
80
+ 'accept': 'application/json;odata=nometadata'
81
+ },
82
+ responseType: 'json'
83
+ };
84
+ return yield request_1.default.get(requestOptions);
85
+ });
86
+ }
87
+ }
88
+ _SpoFileRetentionLabelEnsureCommand_instances = new WeakSet(), _SpoFileRetentionLabelEnsureCommand_initTelemetry = function _SpoFileRetentionLabelEnsureCommand_initTelemetry() {
89
+ this.telemetry.push((args) => {
90
+ Object.assign(this.telemetryProperties, {
91
+ fileUrl: typeof args.options.fileUrl !== 'undefined',
92
+ fileId: typeof args.options.fileId !== 'undefined'
93
+ });
94
+ });
95
+ }, _SpoFileRetentionLabelEnsureCommand_initOptions = function _SpoFileRetentionLabelEnsureCommand_initOptions() {
96
+ this.options.unshift({
97
+ option: '-u, --webUrl <webUrl>'
98
+ }, {
99
+ option: '--name <name>'
100
+ }, {
101
+ option: '--fileUrl [fileUrl]'
102
+ }, {
103
+ option: '-i, --fileId [fileId]'
104
+ });
105
+ }, _SpoFileRetentionLabelEnsureCommand_initValidators = function _SpoFileRetentionLabelEnsureCommand_initValidators() {
106
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
107
+ const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
108
+ if (isValidSharePointUrl !== true) {
109
+ return isValidSharePointUrl;
110
+ }
111
+ if (args.options.fileId &&
112
+ !validation_1.validation.isValidGuid(args.options.fileId)) {
113
+ return `${args.options.fileId} is not a valid GUID`;
114
+ }
115
+ return true;
116
+ }));
117
+ }, _SpoFileRetentionLabelEnsureCommand_initOptionSets = function _SpoFileRetentionLabelEnsureCommand_initOptionSets() {
118
+ this.optionSets.push({ options: ['fileUrl', 'fileId'] });
119
+ };
120
+ module.exports = new SpoFileRetentionLabelEnsureCommand();
121
+ //# sourceMappingURL=file-retentionlabel-ensure.js.map
@@ -0,0 +1,141 @@
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 _SpoFileRetentionLabelRemoveCommand_instances, _SpoFileRetentionLabelRemoveCommand_initTelemetry, _SpoFileRetentionLabelRemoveCommand_initOptions, _SpoFileRetentionLabelRemoveCommand_initValidators, _SpoFileRetentionLabelRemoveCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
19
+ const request_1 = require("../../../../request");
20
+ const validation_1 = require("../../../../utils/validation");
21
+ const SpoCommand_1 = require("../../../base/SpoCommand");
22
+ const commands_1 = require("../../commands");
23
+ const SpoListItemRetentionLabelRemoveCommand = require("../listitem/listitem-retentionlabel-remove");
24
+ const formatting_1 = require("../../../../utils/formatting");
25
+ const urlUtil_1 = require("../../../../utils/urlUtil");
26
+ class SpoFileRetentionLabelRemoveCommand extends SpoCommand_1.default {
27
+ get name() {
28
+ return commands_1.default.FILE_RETENTIONLABEL_REMOVE;
29
+ }
30
+ get description() {
31
+ return 'Clear the retention label from a file';
32
+ }
33
+ constructor() {
34
+ super();
35
+ _SpoFileRetentionLabelRemoveCommand_instances.add(this);
36
+ __classPrivateFieldGet(this, _SpoFileRetentionLabelRemoveCommand_instances, "m", _SpoFileRetentionLabelRemoveCommand_initTelemetry).call(this);
37
+ __classPrivateFieldGet(this, _SpoFileRetentionLabelRemoveCommand_instances, "m", _SpoFileRetentionLabelRemoveCommand_initOptions).call(this);
38
+ __classPrivateFieldGet(this, _SpoFileRetentionLabelRemoveCommand_instances, "m", _SpoFileRetentionLabelRemoveCommand_initValidators).call(this);
39
+ __classPrivateFieldGet(this, _SpoFileRetentionLabelRemoveCommand_instances, "m", _SpoFileRetentionLabelRemoveCommand_initOptionSets).call(this);
40
+ }
41
+ commandAction(logger, args) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ if (args.options.confirm) {
44
+ yield this.removeFileRetentionLabel(logger, args);
45
+ }
46
+ else {
47
+ const result = yield Cli_1.Cli.prompt({
48
+ type: 'confirm',
49
+ name: 'continue',
50
+ default: false,
51
+ message: `Are you sure you want to remove the retentionlabel from file ${args.options.fileId || args.options.fileUrl} located in site ${args.options.webUrl}?`
52
+ });
53
+ if (result.continue) {
54
+ yield this.removeFileRetentionLabel(logger, args);
55
+ }
56
+ }
57
+ });
58
+ }
59
+ removeFileRetentionLabel(logger, args) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ if (this.verbose) {
62
+ logger.logToStderr(`Removing retention label from file ${args.options.fileId || args.options.fileUrl} in site at ${args.options.webUrl}...`);
63
+ }
64
+ try {
65
+ const fileProperties = yield this.getFileProperties(args);
66
+ const options = {
67
+ webUrl: args.options.webUrl,
68
+ listId: fileProperties.listId,
69
+ listItemId: fileProperties.id,
70
+ confirm: true,
71
+ output: 'json',
72
+ debug: this.debug,
73
+ verbose: this.verbose
74
+ };
75
+ const spoListItemRetentionLabelRemoveCommandOutput = yield Cli_1.Cli.executeCommandWithOutput(SpoListItemRetentionLabelRemoveCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
76
+ if (this.verbose) {
77
+ logger.logToStderr(spoListItemRetentionLabelRemoveCommandOutput.stderr);
78
+ }
79
+ }
80
+ catch (err) {
81
+ this.handleRejectedODataJsonPromise(err);
82
+ }
83
+ });
84
+ }
85
+ getFileProperties(args) {
86
+ return __awaiter(this, void 0, void 0, function* () {
87
+ const requestOptions = {
88
+ headers: {
89
+ 'accept': 'application/json;odata=nometadata'
90
+ },
91
+ responseType: 'json'
92
+ };
93
+ let requestUrl = `${args.options.webUrl}/_api/web/`;
94
+ if (args.options.fileId) {
95
+ requestUrl += `GetFileById('${args.options.fileId}')`;
96
+ }
97
+ else {
98
+ const serverRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.fileUrl);
99
+ requestUrl += `GetFileByServerRelativeUrl('${formatting_1.formatting.encodeQueryParameter(serverRelativeUrl)}')`;
100
+ }
101
+ requestOptions.url = `${requestUrl}?$expand=ListItemAllFields,ListItemAllFields/ParentList&$select=ListItemAllFields/ParentList/Id,ListItemAllFields/Id`;
102
+ const response = yield request_1.default.get(requestOptions);
103
+ return { id: response.ListItemAllFields.Id, listId: response.ListItemAllFields.ParentList.Id };
104
+ });
105
+ }
106
+ }
107
+ _SpoFileRetentionLabelRemoveCommand_instances = new WeakSet(), _SpoFileRetentionLabelRemoveCommand_initTelemetry = function _SpoFileRetentionLabelRemoveCommand_initTelemetry() {
108
+ this.telemetry.push((args) => {
109
+ Object.assign(this.telemetryProperties, {
110
+ fileUrl: typeof args.options.fileUrl !== 'undefined',
111
+ fileId: typeof args.options.fileId !== 'undefined',
112
+ confirm: !!args.options.confirm
113
+ });
114
+ });
115
+ }, _SpoFileRetentionLabelRemoveCommand_initOptions = function _SpoFileRetentionLabelRemoveCommand_initOptions() {
116
+ this.options.unshift({
117
+ option: '-u, --webUrl <webUrl>'
118
+ }, {
119
+ option: '--fileUrl [fileUrl]'
120
+ }, {
121
+ option: '-i, --fileId [fileId]'
122
+ }, {
123
+ option: '--confirm'
124
+ });
125
+ }, _SpoFileRetentionLabelRemoveCommand_initValidators = function _SpoFileRetentionLabelRemoveCommand_initValidators() {
126
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
127
+ const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
128
+ if (isValidSharePointUrl !== true) {
129
+ return isValidSharePointUrl;
130
+ }
131
+ if (args.options.fileId &&
132
+ !validation_1.validation.isValidGuid(args.options.fileId)) {
133
+ return `${args.options.fileId} is not a valid GUID`;
134
+ }
135
+ return true;
136
+ }));
137
+ }, _SpoFileRetentionLabelRemoveCommand_initOptionSets = function _SpoFileRetentionLabelRemoveCommand_initOptionSets() {
138
+ this.optionSets.push({ options: ['fileUrl', 'fileId'] });
139
+ };
140
+ module.exports = new SpoFileRetentionLabelRemoveCommand();
141
+ //# sourceMappingURL=file-retentionlabel-remove.js.map
@@ -0,0 +1,141 @@
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 _SpoFileSharingLinkAddCommand_instances, _SpoFileSharingLinkAddCommand_initTelemetry, _SpoFileSharingLinkAddCommand_initOptions, _SpoFileSharingLinkAddCommand_initValidators, _SpoFileSharingLinkAddCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const request_1 = require("../../../../request");
19
+ const formatting_1 = require("../../../../utils/formatting");
20
+ const validation_1 = require("../../../../utils/validation");
21
+ const SpoCommand_1 = require("../../../base/SpoCommand");
22
+ const commands_1 = require("../../commands");
23
+ class SpoFileSharingLinkAddCommand extends SpoCommand_1.default {
24
+ get name() {
25
+ return commands_1.default.FILE_SHARINGLINK_ADD;
26
+ }
27
+ get description() {
28
+ return 'Creates a new sharing link for a file';
29
+ }
30
+ constructor() {
31
+ super();
32
+ _SpoFileSharingLinkAddCommand_instances.add(this);
33
+ __classPrivateFieldGet(this, _SpoFileSharingLinkAddCommand_instances, "m", _SpoFileSharingLinkAddCommand_initTelemetry).call(this);
34
+ __classPrivateFieldGet(this, _SpoFileSharingLinkAddCommand_instances, "m", _SpoFileSharingLinkAddCommand_initOptions).call(this);
35
+ __classPrivateFieldGet(this, _SpoFileSharingLinkAddCommand_instances, "m", _SpoFileSharingLinkAddCommand_initValidators).call(this);
36
+ __classPrivateFieldGet(this, _SpoFileSharingLinkAddCommand_instances, "m", _SpoFileSharingLinkAddCommand_initOptionSets).call(this);
37
+ }
38
+ commandAction(logger, args) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ if (this.verbose) {
41
+ logger.logToStderr(`Creating a sharing link for file ${args.options.fileId || args.options.fileUrl}...`);
42
+ }
43
+ try {
44
+ const fileDetails = yield this.getFileDetails(args.options.webUrl, args.options.fileId, args.options.fileUrl);
45
+ const requestOptions = {
46
+ url: `https://graph.microsoft.com/v1.0/sites/${fileDetails.SiteId}/drives/${fileDetails.VroomDriveID}/items/${fileDetails.VroomItemID}/createLink`,
47
+ headers: {
48
+ accept: 'application/json;odata.metadata=none'
49
+ },
50
+ responseType: 'json',
51
+ data: {
52
+ type: args.options.type,
53
+ expirationDateTime: args.options.expirationDateTime,
54
+ scope: args.options.scope
55
+ }
56
+ };
57
+ const sharingLink = yield request_1.default.post(requestOptions);
58
+ logger.log(sharingLink);
59
+ }
60
+ catch (err) {
61
+ this.handleRejectedODataJsonPromise(err);
62
+ }
63
+ });
64
+ }
65
+ getFileDetails(webUrl, fileId, fileUrl) {
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ let requestUrl = `${webUrl}/_api/web/`;
68
+ if (fileId) {
69
+ requestUrl += `GetFileById('${fileId}')`;
70
+ }
71
+ else if (fileUrl) {
72
+ requestUrl += `GetFileByServerRelativePath(decodedUrl='${formatting_1.formatting.encodeQueryParameter(fileUrl)}')`;
73
+ }
74
+ const requestOptions = {
75
+ url: requestUrl += '?$select=SiteId,VroomItemId,VroomDriveId',
76
+ headers: {
77
+ accept: 'application/json;odata=nometadata'
78
+ },
79
+ responseType: 'json'
80
+ };
81
+ const res = yield request_1.default.get(requestOptions);
82
+ return res;
83
+ });
84
+ }
85
+ }
86
+ _SpoFileSharingLinkAddCommand_instances = new WeakSet(), _SpoFileSharingLinkAddCommand_initTelemetry = function _SpoFileSharingLinkAddCommand_initTelemetry() {
87
+ this.telemetry.push((args) => {
88
+ Object.assign(this.telemetryProperties, {
89
+ fileId: typeof args.options.fileId !== 'undefined',
90
+ fileUrl: typeof args.options.fileUrl !== 'undefined',
91
+ expirationDateTime: typeof args.options.expirationDateTime !== 'undefined',
92
+ scope: typeof args.options.scope !== 'undefined'
93
+ });
94
+ });
95
+ }, _SpoFileSharingLinkAddCommand_initOptions = function _SpoFileSharingLinkAddCommand_initOptions() {
96
+ this.options.unshift({
97
+ option: '-u, --webUrl <webUrl>'
98
+ }, {
99
+ option: '--fileId [fileId]'
100
+ }, {
101
+ option: '--fileUrl [fileUrl]'
102
+ }, {
103
+ option: '--type <type>',
104
+ autocomplete: SpoFileSharingLinkAddCommand.types
105
+ }, {
106
+ option: '--expirationDateTime [expirationDateTime]'
107
+ }, {
108
+ option: '--scope [scope]',
109
+ autocomplete: SpoFileSharingLinkAddCommand.scopes
110
+ });
111
+ }, _SpoFileSharingLinkAddCommand_initValidators = function _SpoFileSharingLinkAddCommand_initValidators() {
112
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
113
+ const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
114
+ if (isValidSharePointUrl !== true) {
115
+ return isValidSharePointUrl;
116
+ }
117
+ if (args.options.fileId && !validation_1.validation.isValidGuid(args.options.fileId)) {
118
+ return `${args.options.fileId} is not a valid GUID`;
119
+ }
120
+ if (SpoFileSharingLinkAddCommand.types.indexOf(args.options.type) < 0) {
121
+ return `'${args.options.type}' is not a valid type. Allowed types are ${SpoFileSharingLinkAddCommand.types.join(', ')}`;
122
+ }
123
+ if (args.options.scope &&
124
+ SpoFileSharingLinkAddCommand.scopes.indexOf(args.options.scope) < 0) {
125
+ return `'${args.options.scope}' is not a valid scope. Allowed scopes are ${SpoFileSharingLinkAddCommand.scopes.join(', ')}`;
126
+ }
127
+ if (args.options.scope && args.options.scope !== 'anonymous' && args.options.expirationDateTime) {
128
+ return `Option expirationDateTime can only be used for links with scope 'anonymous'.`;
129
+ }
130
+ if (args.options.expirationDateTime && !validation_1.validation.isValidISODateTime(args.options.expirationDateTime)) {
131
+ return `${args.options.expirationDateTime} is not a valid ISO date string.`;
132
+ }
133
+ return true;
134
+ }));
135
+ }, _SpoFileSharingLinkAddCommand_initOptionSets = function _SpoFileSharingLinkAddCommand_initOptionSets() {
136
+ this.optionSets.push({ options: ['fileId', 'fileUrl'] });
137
+ };
138
+ SpoFileSharingLinkAddCommand.types = ['view', 'edit'];
139
+ SpoFileSharingLinkAddCommand.scopes = ['anonymous', 'organization'];
140
+ module.exports = new SpoFileSharingLinkAddCommand();
141
+ //# sourceMappingURL=file-sharinglink-add.js.map
@@ -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,16 +96,20 @@ _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() {
98
104
  this.options.unshift({
99
105
  option: '-u, --webUrl <webUrl>'
100
106
  }, {
101
- option: '-i, --fileId [fileId]'
107
+ option: '--fileId [fileId]'
108
+ }, {
109
+ option: '--fileUrl [fileUrl]'
102
110
  }, {
103
- option: '-f, --fileUrl [fileUrl]'
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