@pnp/cli-microsoft365 6.3.0-beta.e46ffee → 6.3.0-beta.fee5cdb

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 (142) hide show
  1. package/.eslintrc.js +8 -0
  2. package/dist/Command.js +12 -1
  3. package/dist/cli/Cli.js +4 -1
  4. package/dist/m365/aad/commands/group/group-list.js +2 -1
  5. package/dist/m365/aad/commands/user/user-recyclebinitem-clear.js +103 -0
  6. package/dist/m365/aad/commands.js +1 -0
  7. package/dist/m365/base/O365MgmtCommand.js +10 -0
  8. package/dist/m365/context/commands/option/option-list.js +54 -0
  9. package/dist/m365/context/commands.js +1 -0
  10. package/dist/m365/graph/commands/changelog/changelog-list.js +3 -2
  11. package/dist/m365/onenote/commands/notebook/notebook-list.js +51 -40
  12. package/dist/m365/pa/commands/environment/environment-get.js +13 -5
  13. package/dist/m365/planner/commands/plan/plan-get.js +40 -26
  14. package/dist/m365/planner/commands/plan/plan-list.js +24 -14
  15. package/dist/m365/planner/commands/plan/plan-set.js +21 -10
  16. package/dist/m365/planner/commands/roster/roster-get.js +61 -0
  17. package/dist/m365/planner/commands/roster/roster-member-add.js +113 -0
  18. package/dist/m365/planner/commands/roster/roster-member-list.js +54 -0
  19. package/dist/m365/planner/commands/roster/roster-member-remove.js +140 -0
  20. package/dist/m365/planner/commands/task/task-add.js +3 -0
  21. package/dist/m365/planner/commands/task/task-checklistitem-add.js +2 -1
  22. package/dist/m365/planner/commands/task/task-checklistitem-list.js +2 -1
  23. package/dist/m365/planner/commands.js +4 -0
  24. package/dist/m365/pp/commands/solution/solution-get.js +2 -1
  25. package/dist/m365/pp/commands/solution/solution-list.js +2 -1
  26. package/dist/m365/purview/commands/auditlog/auditlog-list.js +205 -0
  27. package/dist/m365/purview/commands/retentionevent/retentionevent-get.js +75 -0
  28. package/dist/m365/purview/commands/retentionevent/retentionevent-list.js +46 -0
  29. package/dist/m365/purview/commands/retentionevent/retentionevent-remove.js +97 -0
  30. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-add.js +77 -0
  31. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-get.js +13 -8
  32. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-list.js +43 -0
  33. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-remove.js +97 -0
  34. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-set.js +90 -0
  35. package/dist/m365/purview/commands/retentionlabel/retentionlabel-add.js +5 -0
  36. package/dist/m365/purview/commands/retentionlabel/retentionlabel-get.js +5 -0
  37. package/dist/m365/purview/commands/retentionlabel/retentionlabel-list.js +5 -0
  38. package/dist/m365/purview/commands/retentionlabel/retentionlabel-remove.js +5 -0
  39. package/dist/m365/purview/commands/retentionlabel/retentionlabel-set.js +11 -1
  40. package/dist/m365/purview/commands.js +8 -0
  41. package/dist/m365/spo/commands/app/app-add.js +2 -1
  42. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-add.js +95 -0
  43. package/dist/m365/spo/commands/customaction/customaction-get.js +17 -66
  44. package/dist/m365/spo/commands/customaction/customaction-list.js +2 -36
  45. package/dist/m365/spo/commands/customaction/customaction-remove.js +11 -18
  46. package/dist/m365/spo/commands/file/GraphFileDetails.js +0 -1
  47. package/dist/m365/spo/commands/file/file-sharinginfo-get.js +2 -1
  48. package/dist/m365/spo/commands/file/file-sharinglink-add.js +2 -22
  49. package/dist/m365/spo/commands/file/file-sharinglink-clear.js +137 -0
  50. package/dist/m365/spo/commands/file/file-sharinglink-get.js +2 -25
  51. package/dist/m365/spo/commands/file/file-sharinglink-list.js +9 -29
  52. package/dist/m365/spo/commands/file/file-sharinglink-remove.js +2 -25
  53. package/dist/m365/spo/commands/file/file-sharinglink-set.js +104 -0
  54. package/dist/m365/spo/commands/group/group-list.js +2 -1
  55. package/dist/m365/spo/commands/hubsite/hubsite-get.js +1 -1
  56. package/dist/m365/spo/commands/listitem/listitem-add.js +2 -1
  57. package/dist/m365/spo/commands/listitem/listitem-list.js +2 -1
  58. package/dist/m365/spo/commands/navigation/navigation-node-get.js +73 -0
  59. package/dist/m365/spo/commands/page/page-column-get.js +2 -1
  60. package/dist/m365/spo/commands/page/page-column-list.js +2 -1
  61. package/dist/m365/spo/commands/page/page-section-get.js +2 -1
  62. package/dist/m365/spo/commands/page/page-section-list.js +2 -1
  63. package/dist/m365/spo/commands/sitedesign/sitedesign-add.js +6 -0
  64. package/dist/m365/spo/commands/spo-search.js +2 -1
  65. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-add.js +179 -0
  66. package/dist/m365/spo/commands/term/term-list.js +2 -1
  67. package/dist/m365/spo/commands/userprofile/userprofile-get.js +2 -2
  68. package/dist/m365/spo/commands.js +5 -0
  69. package/dist/m365/teams/commands/meeting/meeting-list.js +1 -1
  70. package/dist/m365/teams/commands/team/team-app-list.js +1 -1
  71. package/dist/m365/teams/commands/user/user-app-list.js +2 -1
  72. package/dist/m365/todo/commands/task/task-get.js +2 -1
  73. package/dist/m365/todo/commands/task/task-list.js +2 -1
  74. package/dist/m365/yammer/commands/yammer-search.js +2 -1
  75. package/dist/utils/aadUser.js +38 -0
  76. package/dist/utils/planner.js +13 -2
  77. package/dist/utils/spo.js +89 -0
  78. package/docs/docs/cmd/aad/user/user-recyclebinitem-clear.md +42 -0
  79. package/docs/docs/cmd/context/option/option-list.md +63 -0
  80. package/docs/docs/cmd/login.md +26 -0
  81. package/docs/docs/cmd/logout.md +4 -0
  82. package/docs/docs/cmd/pa/app/app-get.md +24 -0
  83. package/docs/docs/cmd/pa/app/app-list.md +21 -0
  84. package/docs/docs/cmd/pa/connector/connector-list.md +17 -0
  85. package/docs/docs/cmd/pa/environment/environment-get.md +26 -2
  86. package/docs/docs/cmd/pa/environment/environment-list.md +19 -0
  87. package/docs/docs/cmd/planner/plan/plan-get.md +21 -7
  88. package/docs/docs/cmd/planner/plan/plan-list.md +16 -2
  89. package/docs/docs/cmd/planner/plan/plan-set.md +10 -4
  90. package/docs/docs/cmd/planner/roster/roster-get.md +73 -0
  91. package/docs/docs/cmd/planner/roster/roster-member-add.md +87 -0
  92. package/docs/docs/cmd/planner/roster/roster-member-list.md +76 -0
  93. package/docs/docs/cmd/planner/roster/roster-member-remove.md +51 -0
  94. package/docs/docs/cmd/pp/aibuildermodel/aibuildermodel-get.md +43 -0
  95. package/docs/docs/cmd/pp/aibuildermodel/aibuildermodel-list.md +43 -0
  96. package/docs/docs/cmd/pp/card/card-clone.md +12 -0
  97. package/docs/docs/cmd/pp/card/card-get.md +49 -0
  98. package/docs/docs/cmd/pp/card/card-list.md +49 -0
  99. package/docs/docs/cmd/pp/chatbot/chatbot-get.md +55 -0
  100. package/docs/docs/cmd/pp/chatbot/chatbot-list.md +36 -0
  101. package/docs/docs/cmd/pp/dataverse/dataverse-table-get.md +30 -0
  102. package/docs/docs/cmd/pp/dataverse/dataverse-table-list.md +30 -0
  103. package/docs/docs/cmd/pp/dataverse/dataverse-table-row-list.md +30 -0
  104. package/docs/docs/cmd/pp/environment/environment-get.md +19 -0
  105. package/docs/docs/cmd/pp/environment/environment-list.md +19 -0
  106. package/docs/docs/cmd/pp/gateway/gateway-get.md +19 -0
  107. package/docs/docs/cmd/pp/gateway/gateway-list.md +19 -0
  108. package/docs/docs/cmd/pp/managementapp/managementapp-add.md +12 -0
  109. package/docs/docs/cmd/pp/managementapp/managementapp-list.md +12 -0
  110. package/docs/docs/cmd/pp/solution/solution-get.md +14 -0
  111. package/docs/docs/cmd/pp/solution/solution-list.md +14 -0
  112. package/docs/docs/cmd/pp/solution/solution-publisher-get.md +20 -1
  113. package/docs/docs/cmd/pp/solution/solution-publisher-list.md +18 -0
  114. package/docs/docs/cmd/pp/tenant/tenant-settings-list.md +21 -0
  115. package/docs/docs/cmd/purview/auditlog/auditlog-list.md +123 -0
  116. package/docs/docs/cmd/purview/retentionevent/retentionevent-get.md +132 -0
  117. package/docs/docs/cmd/purview/retentionevent/retentionevent-list.md +107 -0
  118. package/docs/docs/cmd/purview/retentionevent/retentionevent-remove.md +45 -0
  119. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-add.md +106 -0
  120. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-get.md +3 -0
  121. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-list.md +97 -0
  122. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-remove.md +43 -0
  123. package/docs/docs/cmd/purview/retentioneventtype/retentioneventtype-set.md +43 -0
  124. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-add.md +3 -0
  125. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-get.md +3 -0
  126. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-list.md +3 -0
  127. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-remove.md +3 -0
  128. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-set.md +3 -0
  129. package/docs/docs/cmd/request.md +74 -0
  130. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-add.md +56 -0
  131. package/docs/docs/cmd/spo/file/file-sharinglink-clear.md +46 -0
  132. package/docs/docs/cmd/spo/file/file-sharinglink-list.md +1 -1
  133. package/docs/docs/cmd/spo/file/file-sharinglink-set.md +104 -0
  134. package/docs/docs/cmd/spo/navigation/navigation-node-add.md +1 -1
  135. package/docs/docs/cmd/spo/navigation/navigation-node-get.md +91 -0
  136. package/docs/docs/cmd/spo/navigation/navigation-node-set.md +1 -1
  137. package/docs/docs/cmd/spo/sitedesign/sitedesign-add.md +3 -0
  138. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-add.md +59 -0
  139. package/docs/docs/cmd/status.md +46 -0
  140. package/docs/docs/cmd/version.md +26 -0
  141. package/npm-shrinkwrap.json +911 -876
  142. package/package.json +12 -12
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const Cli_1 = require("../../../../cli/Cli");
19
19
  const request_1 = require("../../../../request");
20
20
  const formatting_1 = require("../../../../utils/formatting");
21
+ const spo_1 = require("../../../../utils/spo");
21
22
  const validation_1 = require("../../../../utils/validation");
22
23
  const SpoCommand_1 = require("../../../base/SpoCommand");
23
24
  const commands_1 = require("../../commands");
@@ -74,26 +75,18 @@ class SpoCustomActionRemoveCommand extends SpoCommand_1.default {
74
75
  });
75
76
  }
76
77
  getCustomActionId(options) {
77
- if (options.id) {
78
- return Promise.resolve(options.id);
79
- }
80
- const customActionRequestOptions = {
81
- url: `${options.webUrl}/_api/${options.scope}/UserCustomActions?$filter=Title eq '${formatting_1.formatting.encodeQueryParameter(options.title)}'`,
82
- headers: {
83
- accept: 'application/json;odata=nometadata'
84
- },
85
- responseType: 'json'
86
- };
87
- return request_1.default
88
- .get(customActionRequestOptions)
89
- .then((res) => {
90
- if (res.value.length === 1) {
91
- return Promise.resolve(res.value[0].Id);
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ if (options.id) {
80
+ return Promise.resolve(options.id);
81
+ }
82
+ const customActions = yield spo_1.spo.getCustomActions(options.webUrl, options.scope, `Title eq '${formatting_1.formatting.encodeQueryParameter(options.title)}'`);
83
+ if (customActions.length === 1) {
84
+ return customActions[0].Id;
92
85
  }
93
- if (res.value.length === 0) {
94
- return Promise.reject(`No user custom action with title '${options.title}' found`);
86
+ if (customActions.length === 0) {
87
+ throw `No user custom action with title '${options.title}' found`;
95
88
  }
96
- return Promise.reject(`Multiple user custom actions with title '${options.title}' found. Please disambiguate using IDs: ${res.value.map(a => a.Id).join(', ')}`);
89
+ throw `Multiple user custom actions with title '${options.title}' found. Please disambiguate using IDs: ${customActions.map(a => a.Id).join(', ')}`;
97
90
  });
98
91
  }
99
92
  removeScopedCustomAction(options) {
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
2
  //# sourceMappingURL=GraphFileDetails.js.map
@@ -15,6 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _SpoFileSharingInfoGetCommand_instances, _SpoFileSharingInfoGetCommand_initTelemetry, _SpoFileSharingInfoGetCommand_initOptions, _SpoFileSharingInfoGetCommand_initValidators, _SpoFileSharingInfoGetCommand_initOptionSets;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
18
19
  const request_1 = require("../../../../request");
19
20
  const formatting_1 = require("../../../../utils/formatting");
20
21
  const validation_1 = require("../../../../utils/validation");
@@ -60,7 +61,7 @@ class SpoFileSharingInfoGetCommand extends SpoCommand_1.default {
60
61
  // typically, we don't do this, but in this case, we need to due to
61
62
  // the complexity of the retrieved object and the fact that we can't
62
63
  // use the generic way of simplifying the output
63
- if (args.options.output === 'json') {
64
+ if (!Cli_1.Cli.shouldTrimOutput(args.options.output)) {
64
65
  logger.log(res);
65
66
  }
66
67
  else {
@@ -16,7 +16,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
16
16
  var _SpoFileSharingLinkAddCommand_instances, _SpoFileSharingLinkAddCommand_initTelemetry, _SpoFileSharingLinkAddCommand_initOptions, _SpoFileSharingLinkAddCommand_initValidators, _SpoFileSharingLinkAddCommand_initOptionSets;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const request_1 = require("../../../../request");
19
- const formatting_1 = require("../../../../utils/formatting");
19
+ const spo_1 = require("../../../../utils/spo");
20
20
  const validation_1 = require("../../../../utils/validation");
21
21
  const SpoCommand_1 = require("../../../base/SpoCommand");
22
22
  const commands_1 = require("../../commands");
@@ -41,7 +41,7 @@ class SpoFileSharingLinkAddCommand extends SpoCommand_1.default {
41
41
  logger.logToStderr(`Creating a sharing link for file ${args.options.fileId || args.options.fileUrl}...`);
42
42
  }
43
43
  try {
44
- const fileDetails = yield this.getFileDetails(args.options.webUrl, args.options.fileId, args.options.fileUrl);
44
+ const fileDetails = yield spo_1.spo.getVroomFileDetails(args.options.webUrl, args.options.fileId, args.options.fileUrl);
45
45
  const requestOptions = {
46
46
  url: `https://graph.microsoft.com/v1.0/sites/${fileDetails.SiteId}/drives/${fileDetails.VroomDriveID}/items/${fileDetails.VroomItemID}/createLink`,
47
47
  headers: {
@@ -62,26 +62,6 @@ class SpoFileSharingLinkAddCommand extends SpoCommand_1.default {
62
62
  }
63
63
  });
64
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
65
  }
86
66
  _SpoFileSharingLinkAddCommand_instances = new WeakSet(), _SpoFileSharingLinkAddCommand_initTelemetry = function _SpoFileSharingLinkAddCommand_initTelemetry() {
87
67
  this.telemetry.push((args) => {
@@ -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 _SpoFileSharingLinkClearCommand_instances, _SpoFileSharingLinkClearCommand_initTelemetry, _SpoFileSharingLinkClearCommand_initOptions, _SpoFileSharingLinkClearCommand_initValidators, _SpoFileSharingLinkClearCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const validation_1 = require("../../../../utils/validation");
19
+ const SpoCommand_1 = require("../../../base/SpoCommand");
20
+ const commands_1 = require("../../commands");
21
+ const Cli_1 = require("../../../../cli/Cli");
22
+ const spoFileSharingLinkListCommand = require("./file-sharinglink-list");
23
+ const request_1 = require("../../../../request");
24
+ const spo_1 = require("../../../../utils/spo");
25
+ class SpoFileSharingLinkClearCommand extends SpoCommand_1.default {
26
+ get name() {
27
+ return commands_1.default.FILE_SHARINGLINK_CLEAR;
28
+ }
29
+ get description() {
30
+ return 'Removes sharing links of a file';
31
+ }
32
+ constructor() {
33
+ super();
34
+ _SpoFileSharingLinkClearCommand_instances.add(this);
35
+ this.allowedScopes = ['anonymous', 'users', 'organization'];
36
+ __classPrivateFieldGet(this, _SpoFileSharingLinkClearCommand_instances, "m", _SpoFileSharingLinkClearCommand_initTelemetry).call(this);
37
+ __classPrivateFieldGet(this, _SpoFileSharingLinkClearCommand_instances, "m", _SpoFileSharingLinkClearCommand_initOptions).call(this);
38
+ __classPrivateFieldGet(this, _SpoFileSharingLinkClearCommand_instances, "m", _SpoFileSharingLinkClearCommand_initValidators).call(this);
39
+ __classPrivateFieldGet(this, _SpoFileSharingLinkClearCommand_instances, "m", _SpoFileSharingLinkClearCommand_initOptionSets).call(this);
40
+ }
41
+ commandAction(logger, args) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const clearSharingLinks = () => __awaiter(this, void 0, void 0, function* () {
44
+ try {
45
+ if (this.verbose) {
46
+ logger.logToStderr(`Clearing sharing links for file ${args.options.fileUrl || args.options.fileId}${args.options.scope ? ` with scope ${args.options.scope}` : ''}`);
47
+ }
48
+ const fileDetails = yield spo_1.spo.getVroomFileDetails(args.options.webUrl, args.options.fileId, args.options.fileUrl);
49
+ const sharingLinks = yield this.getFileSharingLinks(args.options.webUrl, args.options.fileId, args.options.fileUrl, args.options.scope);
50
+ const requestOptions = {
51
+ headers: {
52
+ accept: 'application/json;odata.metadata=none'
53
+ },
54
+ responseType: 'json'
55
+ };
56
+ for (const sharingLink of sharingLinks) {
57
+ requestOptions.url = `https://graph.microsoft.com/v1.0/sites/${fileDetails.SiteId}/drives/${fileDetails.VroomDriveID}/items/${fileDetails.VroomItemID}/permissions/${sharingLink.id}`;
58
+ yield request_1.default.delete(requestOptions);
59
+ }
60
+ }
61
+ catch (err) {
62
+ this.handleRejectedODataJsonPromise(err);
63
+ }
64
+ });
65
+ if (args.options.confirm) {
66
+ yield clearSharingLinks();
67
+ }
68
+ else {
69
+ const result = yield Cli_1.Cli.prompt({
70
+ type: 'confirm',
71
+ name: 'continue',
72
+ default: false,
73
+ message: `Are you sure you want to clear the sharing links of file ${args.options.fileUrl || args.options.fileId}${args.options.scope ? ` with scope ${args.options.scope}` : ''}?`
74
+ });
75
+ if (result.continue) {
76
+ yield clearSharingLinks();
77
+ }
78
+ }
79
+ });
80
+ }
81
+ getFileSharingLinks(webUrl, fileId, fileUrl, scope) {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ const sharingLinkListOptions = {
84
+ webUrl: webUrl,
85
+ fileId: fileId,
86
+ fileUrl: fileUrl,
87
+ scope: scope,
88
+ debug: this.debug,
89
+ verbose: this.verbose
90
+ };
91
+ const commandOutput = yield Cli_1.Cli.executeCommandWithOutput(spoFileSharingLinkListCommand, { options: Object.assign(Object.assign({}, sharingLinkListOptions), { _: [] }) });
92
+ const outputParsed = JSON.parse(commandOutput.stdout);
93
+ return outputParsed;
94
+ });
95
+ }
96
+ }
97
+ _SpoFileSharingLinkClearCommand_instances = new WeakSet(), _SpoFileSharingLinkClearCommand_initTelemetry = function _SpoFileSharingLinkClearCommand_initTelemetry() {
98
+ this.telemetry.push((args) => {
99
+ Object.assign(this.telemetryProperties, {
100
+ fileUrl: typeof args.options.fileUrl !== 'undefined',
101
+ fileId: typeof args.options.fileId !== 'undefined',
102
+ scope: typeof args.options.scope !== 'undefined',
103
+ confirm: !!args.options.confirm
104
+ });
105
+ });
106
+ }, _SpoFileSharingLinkClearCommand_initOptions = function _SpoFileSharingLinkClearCommand_initOptions() {
107
+ this.options.unshift({
108
+ option: '-u, --webUrl <webUrl>'
109
+ }, {
110
+ option: '--fileUrl [fileUrl]'
111
+ }, {
112
+ option: '--fileId [fileId]'
113
+ }, {
114
+ option: '-s, --scope [scope]',
115
+ autocomplete: this.allowedScopes
116
+ }, {
117
+ option: '--confirm'
118
+ });
119
+ }, _SpoFileSharingLinkClearCommand_initValidators = function _SpoFileSharingLinkClearCommand_initValidators() {
120
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
121
+ const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
122
+ if (isValidSharePointUrl !== true) {
123
+ return isValidSharePointUrl;
124
+ }
125
+ if (args.options.fileId && !validation_1.validation.isValidGuid(args.options.fileId)) {
126
+ return `${args.options.fileId} is not a valid GUID`;
127
+ }
128
+ if (args.options.scope && this.allowedScopes.indexOf(args.options.scope) === -1) {
129
+ return `'${args.options.scope}' is not a valid scope. Allowed values are: ${this.allowedScopes.join(',')}`;
130
+ }
131
+ return true;
132
+ }));
133
+ }, _SpoFileSharingLinkClearCommand_initOptionSets = function _SpoFileSharingLinkClearCommand_initOptionSets() {
134
+ this.optionSets.push({ options: ['fileUrl', 'fileId'] });
135
+ };
136
+ module.exports = new SpoFileSharingLinkClearCommand();
137
+ //# sourceMappingURL=file-sharinglink-clear.js.map
@@ -16,8 +16,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
16
16
  var _SpoFileSharingLinkGetCommand_instances, _SpoFileSharingLinkGetCommand_initTelemetry, _SpoFileSharingLinkGetCommand_initOptions, _SpoFileSharingLinkGetCommand_initValidators, _SpoFileSharingLinkGetCommand_initOptionSets;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const request_1 = require("../../../../request");
19
- const formatting_1 = require("../../../../utils/formatting");
20
- const urlUtil_1 = require("../../../../utils/urlUtil");
19
+ const spo_1 = require("../../../../utils/spo");
21
20
  const validation_1 = require("../../../../utils/validation");
22
21
  const SpoCommand_1 = require("../../../base/SpoCommand");
23
22
  const commands_1 = require("../../commands");
@@ -42,7 +41,7 @@ class SpoFileSharingLinkGetCommand extends SpoCommand_1.default {
42
41
  logger.logToStderr(`Retrieving sharing link for file ${args.options.fileUrl || args.options.fileId} with id ${args.options.id}...`);
43
42
  }
44
43
  try {
45
- const fileDetails = yield this.getNeededFileInformation(args);
44
+ const fileDetails = yield spo_1.spo.getVroomFileDetails(args.options.webUrl, args.options.fileId, args.options.fileUrl);
46
45
  const requestOptions = {
47
46
  url: `https://graph.microsoft.com/v1.0/sites/${fileDetails.SiteId}/drives/${fileDetails.VroomDriveID}/items/${fileDetails.VroomItemID}/permissions/${args.options.id}`,
48
47
  headers: {
@@ -58,28 +57,6 @@ class SpoFileSharingLinkGetCommand extends SpoCommand_1.default {
58
57
  }
59
58
  });
60
59
  }
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
60
  }
84
61
  _SpoFileSharingLinkGetCommand_instances = new WeakSet(), _SpoFileSharingLinkGetCommand_initTelemetry = function _SpoFileSharingLinkGetCommand_initTelemetry() {
85
62
  this.telemetry.push((args) => {
@@ -15,9 +15,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _SpoFileSharingLinkListCommand_instances, _SpoFileSharingLinkListCommand_initTelemetry, _SpoFileSharingLinkListCommand_initOptions, _SpoFileSharingLinkListCommand_initValidators, _SpoFileSharingLinkListCommand_initOptionSets;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- const request_1 = require("../../../../request");
19
- const formatting_1 = require("../../../../utils/formatting");
18
+ const Cli_1 = require("../../../../cli/Cli");
20
19
  const odata_1 = require("../../../../utils/odata");
20
+ const spo_1 = require("../../../../utils/spo");
21
21
  const validation_1 = require("../../../../utils/validation");
22
22
  const SpoCommand_1 = require("../../../base/SpoCommand");
23
23
  const commands_1 = require("../../commands");
@@ -45,13 +45,13 @@ class SpoFileSharingLinkListCommand extends SpoCommand_1.default {
45
45
  logger.logToStderr(`Retrieving sharing links for file ${args.options.fileId || args.options.fileUrl}...`);
46
46
  }
47
47
  try {
48
- const fileDetails = yield this.getFileDetails(args.options.webUrl, args.options.fileId, args.options.fileUrl);
48
+ const fileDetails = yield spo_1.spo.getVroomFileDetails(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
50
  if (args.options.scope) {
51
51
  url += ` and Link/Scope eq '${args.options.scope}'`;
52
52
  }
53
53
  const sharingLinks = yield odata_1.odata.getAllItems(url);
54
- if (!args.options.output || args.options.output === 'json' || args.options.output === 'md') {
54
+ if (!args.options.output || !Cli_1.Cli.shouldTrimOutput(args.options.output)) {
55
55
  logger.log(sharingLinks);
56
56
  }
57
57
  else {
@@ -71,26 +71,6 @@ class SpoFileSharingLinkListCommand extends SpoCommand_1.default {
71
71
  }
72
72
  });
73
73
  }
74
- getFileDetails(webUrl, fileId, fileUrl) {
75
- return __awaiter(this, void 0, void 0, function* () {
76
- let requestUrl = `${webUrl}/_api/web/`;
77
- if (fileId) {
78
- requestUrl += `GetFileById('${fileId}')`;
79
- }
80
- else if (fileUrl) {
81
- requestUrl += `GetFileByServerRelativePath(decodedUrl='${formatting_1.formatting.encodeQueryParameter(fileUrl)}')`;
82
- }
83
- const requestOptions = {
84
- url: requestUrl += '?$select=SiteId,VroomItemId,VroomDriveId',
85
- headers: {
86
- accept: 'application/json;odata=nometadata'
87
- },
88
- responseType: 'json'
89
- };
90
- const res = yield request_1.default.get(requestOptions);
91
- return res;
92
- });
93
- }
94
74
  }
95
75
  _SpoFileSharingLinkListCommand_instances = new WeakSet(), _SpoFileSharingLinkListCommand_initTelemetry = function _SpoFileSharingLinkListCommand_initTelemetry() {
96
76
  this.telemetry.push((args) => {
@@ -108,8 +88,8 @@ _SpoFileSharingLinkListCommand_instances = new WeakSet(), _SpoFileSharingLinkLis
108
88
  }, {
109
89
  option: '--fileUrl [fileUrl]'
110
90
  }, {
111
- option: '--scope [scope]',
112
- autocomplete: SpoFileSharingLinkListCommand.scope
91
+ option: '-s, --scope [scope]',
92
+ autocomplete: SpoFileSharingLinkListCommand.allowedScopes
113
93
  });
114
94
  }, _SpoFileSharingLinkListCommand_initValidators = function _SpoFileSharingLinkListCommand_initValidators() {
115
95
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
@@ -120,14 +100,14 @@ _SpoFileSharingLinkListCommand_instances = new WeakSet(), _SpoFileSharingLinkLis
120
100
  if (args.options.fileId && !validation_1.validation.isValidGuid(args.options.fileId)) {
121
101
  return `${args.options.fileId} is not a valid GUID`;
122
102
  }
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(',')}`;
103
+ if (args.options.scope && SpoFileSharingLinkListCommand.allowedScopes.indexOf(args.options.scope) === -1) {
104
+ return `'${args.options.scope}' is not a valid scope. Allowed values are: ${SpoFileSharingLinkListCommand.allowedScopes.join(',')}`;
125
105
  }
126
106
  return true;
127
107
  }));
128
108
  }, _SpoFileSharingLinkListCommand_initOptionSets = function _SpoFileSharingLinkListCommand_initOptionSets() {
129
109
  this.optionSets.push({ options: ['fileId', 'fileUrl'] });
130
110
  };
131
- SpoFileSharingLinkListCommand.scope = ['anonymous', 'users', 'organization'];
111
+ SpoFileSharingLinkListCommand.allowedScopes = ['anonymous', 'users', 'organization'];
132
112
  module.exports = new SpoFileSharingLinkListCommand();
133
113
  //# sourceMappingURL=file-sharinglink-list.js.map
@@ -17,8 +17,7 @@ var _SpoFileSharingLinkRemoveCommand_instances, _SpoFileSharingLinkRemoveCommand
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const Cli_1 = require("../../../../cli/Cli");
19
19
  const request_1 = require("../../../../request");
20
- const formatting_1 = require("../../../../utils/formatting");
21
- const urlUtil_1 = require("../../../../utils/urlUtil");
20
+ const spo_1 = require("../../../../utils/spo");
22
21
  const validation_1 = require("../../../../utils/validation");
23
22
  const SpoCommand_1 = require("../../../base/SpoCommand");
24
23
  const commands_1 = require("../../commands");
@@ -44,7 +43,7 @@ class SpoFileSharingLinkRemoveCommand extends SpoCommand_1.default {
44
43
  if (this.verbose) {
45
44
  logger.logToStderr(`Removing sharing link of file ${args.options.fileUrl || args.options.fileId} with id ${args.options.id}...`);
46
45
  }
47
- const fileDetails = yield this.getNeededFileInformation(args);
46
+ const fileDetails = yield spo_1.spo.getVroomFileDetails(args.options.webUrl, args.options.fileId, args.options.fileUrl);
48
47
  const requestOptions = {
49
48
  url: `https://graph.microsoft.com/v1.0/sites/${fileDetails.SiteId}/drives/${fileDetails.VroomDriveID}/items/${fileDetails.VroomItemID}/permissions/${args.options.id}`,
50
49
  headers: {
@@ -74,28 +73,6 @@ class SpoFileSharingLinkRemoveCommand extends SpoCommand_1.default {
74
73
  }
75
74
  });
76
75
  }
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
76
  }
100
77
  _SpoFileSharingLinkRemoveCommand_instances = new WeakSet(), _SpoFileSharingLinkRemoveCommand_initTelemetry = function _SpoFileSharingLinkRemoveCommand_initTelemetry() {
101
78
  this.telemetry.push((args) => {
@@ -0,0 +1,104 @@
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 _SpoFileSharingLinkSetCommand_instances, _SpoFileSharingLinkSetCommand_initTelemetry, _SpoFileSharingLinkSetCommand_initOptions, _SpoFileSharingLinkSetCommand_initValidators, _SpoFileSharingLinkSetCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const request_1 = require("../../../../request");
19
+ const validation_1 = require("../../../../utils/validation");
20
+ const SpoCommand_1 = require("../../../base/SpoCommand");
21
+ const commands_1 = require("../../commands");
22
+ const spo_1 = require("../../../../utils/spo");
23
+ class SpoFileSharingLinkSetCommand extends SpoCommand_1.default {
24
+ get name() {
25
+ return commands_1.default.FILE_SHARINGLINK_SET;
26
+ }
27
+ get description() {
28
+ return 'Updates a sharing link of a file';
29
+ }
30
+ constructor() {
31
+ super();
32
+ _SpoFileSharingLinkSetCommand_instances.add(this);
33
+ __classPrivateFieldGet(this, _SpoFileSharingLinkSetCommand_instances, "m", _SpoFileSharingLinkSetCommand_initTelemetry).call(this);
34
+ __classPrivateFieldGet(this, _SpoFileSharingLinkSetCommand_instances, "m", _SpoFileSharingLinkSetCommand_initOptions).call(this);
35
+ __classPrivateFieldGet(this, _SpoFileSharingLinkSetCommand_instances, "m", _SpoFileSharingLinkSetCommand_initValidators).call(this);
36
+ __classPrivateFieldGet(this, _SpoFileSharingLinkSetCommand_instances, "m", _SpoFileSharingLinkSetCommand_initOptionSets).call(this);
37
+ }
38
+ commandAction(logger, args) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ if (this.verbose) {
41
+ logger.logToStderr(`Updating sharing link of file ${args.options.fileId || args.options.fileUrl}...`);
42
+ }
43
+ try {
44
+ const fileDetails = yield spo_1.spo.getVroomFileDetails(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}/permissions/${args.options.id}`,
47
+ headers: {
48
+ accept: 'application/json;odata.metadata=none'
49
+ },
50
+ responseType: 'json',
51
+ data: {
52
+ expirationDateTime: args.options.expirationDateTime
53
+ }
54
+ };
55
+ const sharingLink = yield request_1.default.patch(requestOptions);
56
+ logger.log(sharingLink);
57
+ }
58
+ catch (err) {
59
+ this.handleRejectedODataJsonPromise(err);
60
+ }
61
+ });
62
+ }
63
+ }
64
+ _SpoFileSharingLinkSetCommand_instances = new WeakSet(), _SpoFileSharingLinkSetCommand_initTelemetry = function _SpoFileSharingLinkSetCommand_initTelemetry() {
65
+ this.telemetry.push((args) => {
66
+ Object.assign(this.telemetryProperties, {
67
+ fileId: typeof args.options.fileId !== 'undefined',
68
+ fileUrl: typeof args.options.fileUrl !== 'undefined'
69
+ });
70
+ });
71
+ }, _SpoFileSharingLinkSetCommand_initOptions = function _SpoFileSharingLinkSetCommand_initOptions() {
72
+ this.options.unshift({
73
+ option: '-u, --webUrl <webUrl>'
74
+ }, {
75
+ option: '--fileId [fileId]'
76
+ }, {
77
+ option: '--fileUrl [fileUrl]'
78
+ }, {
79
+ option: '--id <id>'
80
+ }, {
81
+ option: '--expirationDateTime <expirationDateTime>'
82
+ });
83
+ }, _SpoFileSharingLinkSetCommand_initValidators = function _SpoFileSharingLinkSetCommand_initValidators() {
84
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
85
+ const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
86
+ if (isValidSharePointUrl !== true) {
87
+ return isValidSharePointUrl;
88
+ }
89
+ if (args.options.fileId && !validation_1.validation.isValidGuid(args.options.fileId)) {
90
+ return `${args.options.fileId} is not a valid GUID`;
91
+ }
92
+ if (!validation_1.validation.isValidGuid(args.options.id)) {
93
+ return `${args.options.id} is not a valid GUID`;
94
+ }
95
+ if (!validation_1.validation.isValidISODateTime(args.options.expirationDateTime)) {
96
+ return `'${args.options.expirationDateTime}' is not a valid ISO date string`;
97
+ }
98
+ return true;
99
+ }));
100
+ }, _SpoFileSharingLinkSetCommand_initOptionSets = function _SpoFileSharingLinkSetCommand_initOptionSets() {
101
+ this.optionSets.push({ options: ['fileId', 'fileUrl'] });
102
+ };
103
+ module.exports = new SpoFileSharingLinkSetCommand();
104
+ //# sourceMappingURL=file-sharinglink-set.js.map
@@ -15,6 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _SpoGroupListCommand_instances, _SpoGroupListCommand_initTelemetry, _SpoGroupListCommand_initOptions, _SpoGroupListCommand_initValidators;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
18
19
  const request_1 = require("../../../../request");
19
20
  const odata_1 = require("../../../../utils/odata");
20
21
  const validation_1 = require("../../../../utils/validation");
@@ -73,7 +74,7 @@ class SpoGroupListCommand extends SpoCommand_1.default {
73
74
  };
74
75
  const groupProperties = yield request_1.default.get(requestOptions);
75
76
  logger.log(groupProperties);
76
- if (!options.output || options.output === 'json') {
77
+ if (!options.output || !Cli_1.Cli.shouldTrimOutput(options.output)) {
77
78
  logger.log(groupProperties);
78
79
  }
79
80
  else {
@@ -45,7 +45,7 @@ class SpoHubSiteGetCommand extends SpoCommand_1.default {
45
45
  if (args.options.includeAssociatedSites && (args.options.output && args.options.output !== 'json')) {
46
46
  throw 'includeAssociatedSites option is only allowed with json output mode';
47
47
  }
48
- if (args.options.includeAssociatedSites === true && args.options.output && args.options.output === 'json') {
48
+ if (args.options.includeAssociatedSites === true && args.options.output && !Cli_1.Cli.shouldTrimOutput(args.options.output)) {
49
49
  const spoAdminUrl = yield spo_1.spo.getSpoAdminUrl(logger, this.debug);
50
50
  const associatedSitesCommandOutput = yield this.getAssociatedSites(spoAdminUrl, hubSite.SiteId, logger, args);
51
51
  const associatedSites = JSON.parse(associatedSitesCommandOutput.stdout);
@@ -176,7 +176,8 @@ class SpoListItemAddCommand extends SpoCommand_1.default {
176
176
  'folder',
177
177
  'debug',
178
178
  'verbose',
179
- 'output'
179
+ 'output',
180
+ '_'
180
181
  ];
181
182
  Object.keys(options).forEach(key => {
182
183
  if (excludeOptions.indexOf(key) === -1) {
@@ -15,6 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _SpoListItemListCommand_instances, _SpoListItemListCommand_initTelemetry, _SpoListItemListCommand_initOptions, _SpoListItemListCommand_initValidators, _SpoListItemListCommand_initOptionSets, _SpoListItemListCommand_initTypes;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
18
19
  const request_1 = require("../../../../request");
19
20
  const formatting_1 = require("../../../../utils/formatting");
20
21
  const spo_1 = require("../../../../utils/spo");
@@ -53,7 +54,7 @@ class SpoListItemListCommand extends SpoCommand_1.default {
53
54
  }
54
55
  let formDigestValue = '';
55
56
  const fieldsArray = args.options.fields ? args.options.fields.split(",")
56
- : (!args.options.output || args.options.output === "text") ? ["Title", "Id"] : [];
57
+ : (!args.options.output || Cli_1.Cli.shouldTrimOutput(args.options.output)) ? ["Title", "Id"] : [];
57
58
  const fieldsWithSlash = fieldsArray.filter(item => item.includes('/'));
58
59
  const fieldsToExpand = fieldsWithSlash.map(e => e.split('/')[0]);
59
60
  const expandFieldsArray = fieldsToExpand.filter((item, pos) => fieldsToExpand.indexOf(item) === pos);