@pnp/cli-microsoft365 6.2.0 → 6.3.0-beta.3f7129c

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 (41) hide show
  1. package/dist/Auth.js +0 -18
  2. package/dist/m365/file/commands/convert/convert-pdf.js +7 -6
  3. package/dist/m365/flow/commands/run/run-list.js +55 -3
  4. package/dist/m365/onenote/commands/notebook/notebook-list.js +2 -16
  5. package/dist/m365/onenote/commands/page/page-list.js +2 -16
  6. package/dist/m365/outlook/commands/mail/mail-send.js +3 -2
  7. package/dist/m365/outlook/commands/message/message-get.js +4 -3
  8. package/dist/m365/planner/commands/roster/roster-add.js +47 -0
  9. package/dist/m365/planner/commands/roster/roster-remove.js +88 -0
  10. package/dist/m365/planner/commands.js +2 -0
  11. package/dist/m365/spo/commands/navigation/navigation-node-add.js +17 -3
  12. package/dist/m365/spo/commands/navigation/navigation-node-list.js +4 -7
  13. package/dist/m365/spo/commands/navigation/navigation-node-set.js +118 -0
  14. package/dist/m365/spo/commands/site/site-apppermission-add.js +2 -14
  15. package/dist/m365/spo/commands/site/site-apppermission-get.js +2 -14
  16. package/dist/m365/spo/commands/site/site-apppermission-list.js +2 -14
  17. package/dist/m365/spo/commands/site/site-apppermission-remove.js +2 -14
  18. package/dist/m365/spo/commands/site/site-apppermission-set.js +2 -14
  19. package/dist/m365/spo/commands/web/web-set.js +11 -4
  20. package/dist/m365/spo/commands.js +1 -0
  21. package/dist/m365/teams/commands/chat/chat-list.js +4 -4
  22. package/dist/m365/teams/commands/meeting/meeting-attendancereport-list.js +5 -5
  23. package/dist/m365/teams/commands/meeting/meeting-get.js +5 -5
  24. package/dist/m365/teams/commands/meeting/meeting-list.js +4 -3
  25. package/dist/utils/accessToken.js +1 -1
  26. package/dist/utils/spo.js +27 -0
  27. package/docs/docs/cmd/aad/app/app-list.md +3 -0
  28. package/docs/docs/cmd/aad/user/user-set.md +1 -1
  29. package/docs/docs/cmd/flow/run/run-list.md +21 -0
  30. package/docs/docs/cmd/planner/plan/plan-remove.md +4 -0
  31. package/docs/docs/cmd/planner/roster/roster-add.md +60 -0
  32. package/docs/docs/cmd/planner/roster/roster-remove.md +48 -0
  33. package/docs/docs/cmd/spo/listitem/listitem-attachment-list.md +2 -2
  34. package/docs/docs/cmd/spo/listitem/listitem-isrecord.md +2 -2
  35. package/docs/docs/cmd/spo/navigation/navigation-node-add.md +18 -3
  36. package/docs/docs/cmd/spo/navigation/navigation-node-list.md +30 -0
  37. package/docs/docs/cmd/spo/navigation/navigation-node-remove.md +1 -1
  38. package/docs/docs/cmd/spo/navigation/navigation-node-set.md +59 -0
  39. package/docs/docs/cmd/spo/web/web-set.md +9 -0
  40. package/npm-shrinkwrap.json +2 -2
  41. package/package.json +2 -2
package/dist/Auth.js CHANGED
@@ -573,24 +573,6 @@ class Auth {
573
573
  getMsalCacheStorage() {
574
574
  return new FileTokenStorage_1.FileTokenStorage(FileTokenStorage_1.FileTokenStorage.msalCacheFilePath());
575
575
  }
576
- static isAppOnlyAuth(accessToken) {
577
- let isAppOnlyAuth;
578
- if (!accessToken || accessToken.length === 0) {
579
- return isAppOnlyAuth;
580
- }
581
- const chunks = accessToken.split('.');
582
- if (chunks.length !== 3) {
583
- return isAppOnlyAuth;
584
- }
585
- const tokenString = Buffer.from(chunks[1], 'base64').toString();
586
- try {
587
- const token = JSON.parse(tokenString);
588
- isAppOnlyAuth = !token.upn;
589
- }
590
- catch (_a) {
591
- }
592
- return isAppOnlyAuth;
593
- }
594
576
  }
595
577
  exports.Auth = Auth;
596
578
  exports.default = new Auth();
@@ -23,6 +23,7 @@ const uuid_1 = require("uuid");
23
23
  const Auth_1 = require("../../../../Auth");
24
24
  const Command_1 = require("../../../../Command");
25
25
  const request_1 = require("../../../../request");
26
+ const accessToken_1 = require("../../../../utils/accessToken");
26
27
  const GraphCommand_1 = require("../../../base/GraphCommand");
27
28
  const commands_1 = require("../../commands");
28
29
  class FileConvertPdfCommand extends GraphCommand_1.default {
@@ -46,8 +47,8 @@ class FileConvertPdfCommand extends GraphCommand_1.default {
46
47
  let sourceIsLocalFile = true;
47
48
  let targetIsLocalFile = true;
48
49
  let error;
49
- const isAppOnlyAuth = Auth_1.Auth.isAppOnlyAuth(Auth_1.default.service.accessTokens[Auth_1.default.defaultResource].accessToken);
50
- if (typeof isAppOnlyAuth === 'undefined') {
50
+ const isAppOnlyAccessToken = accessToken_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[Auth_1.default.defaultResource].accessToken);
51
+ if (typeof isAppOnlyAccessToken === 'undefined') {
51
52
  throw 'Unable to determine authentication type';
52
53
  }
53
54
  if (args.options.sourceFile.toLowerCase().startsWith('https://')) {
@@ -62,7 +63,7 @@ class FileConvertPdfCommand extends GraphCommand_1.default {
62
63
  }
63
64
  try {
64
65
  try {
65
- sourceFileUrl = yield this.getSourceFileUrl(logger, args, isAppOnlyAuth);
66
+ sourceFileUrl = yield this.getSourceFileUrl(logger, args, isAppOnlyAccessToken);
66
67
  const graphFileUrl = yield this.getGraphFileUrl(logger, sourceFileUrl, this.sourceFileGraphUrl);
67
68
  const fileResponse = yield this.convertFile(logger, graphFileUrl);
68
69
  yield this.writeFileToDisk(logger, fileResponse, localTargetFilePath);
@@ -114,17 +115,17 @@ class FileConvertPdfCommand extends GraphCommand_1.default {
114
115
  * file to the user's OneDrive for Business
115
116
  * @param logger Logger instance
116
117
  * @param args Command args
117
- * @param isAppOnlyAuth True if CLI is authenticated in app-only mode
118
+ * @param isAppOnlyAccessToken True if CLI is authenticated in app-only mode
118
119
  * @returns Web URL of the file to upload
119
120
  */
120
- getSourceFileUrl(logger, args, isAppOnlyAuth) {
121
+ getSourceFileUrl(logger, args, isAppOnlyAccessToken) {
121
122
  if (args.options.sourceFile.toLowerCase().startsWith('https://')) {
122
123
  return Promise.resolve(args.options.sourceFile);
123
124
  }
124
125
  if (this.verbose) {
125
126
  logger.logToStderr('Uploading local file temporarily for conversion...');
126
127
  }
127
- const driveUrl = `${this.resource}/v1.0/${isAppOnlyAuth ? 'drive/root' : 'me/drive/root'}`;
128
+ const driveUrl = `${this.resource}/v1.0/${isAppOnlyAccessToken ? 'drive/root' : 'me/drive/root'}`;
128
129
  // we need the original file extension because otherwise Graph won't be able
129
130
  // to convert the file to PDF
130
131
  this.sourceFileGraphUrl = `${driveUrl}:/${(0, uuid_1.v4)()}${path.extname(args.options.sourceFile)}`;
@@ -13,9 +13,10 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
14
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
15
  };
16
- var _FlowRunListCommand_instances, _FlowRunListCommand_initOptions;
16
+ var _FlowRunListCommand_instances, _FlowRunListCommand_initTelemetry, _FlowRunListCommand_initOptions, _FlowRunListCommand_initValidators;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const formatting_1 = require("../../../../utils/formatting");
19
+ const validation_1 = require("../../../../utils/validation");
19
20
  const AzmgmtItemsListCommand_1 = require("../../../base/AzmgmtItemsListCommand");
20
21
  const commands_1 = require("../../commands");
21
22
  class FlowRunListCommand extends AzmgmtItemsListCommand_1.AzmgmtItemsListCommand {
@@ -31,14 +32,21 @@ class FlowRunListCommand extends AzmgmtItemsListCommand_1.AzmgmtItemsListCommand
31
32
  constructor() {
32
33
  super();
33
34
  _FlowRunListCommand_instances.add(this);
35
+ this.allowedStatusses = ['Succeeded', 'Running', 'Failed', 'Cancelled'];
36
+ __classPrivateFieldGet(this, _FlowRunListCommand_instances, "m", _FlowRunListCommand_initTelemetry).call(this);
34
37
  __classPrivateFieldGet(this, _FlowRunListCommand_instances, "m", _FlowRunListCommand_initOptions).call(this);
38
+ __classPrivateFieldGet(this, _FlowRunListCommand_instances, "m", _FlowRunListCommand_initValidators).call(this);
35
39
  }
36
40
  commandAction(logger, args) {
37
41
  return __awaiter(this, void 0, void 0, function* () {
38
42
  if (this.verbose) {
39
43
  logger.logToStderr(`Retrieving list of runs for Microsoft Flow ${args.options.flowName}...`);
40
44
  }
41
- const url = `${this.resource}providers/Microsoft.ProcessSimple/environments/${formatting_1.formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting_1.formatting.encodeQueryParameter(args.options.flowName)}/runs?api-version=2016-11-01`;
45
+ let url = `${this.resource}providers/Microsoft.ProcessSimple/environments/${formatting_1.formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting_1.formatting.encodeQueryParameter(args.options.flowName)}/runs?api-version=2016-11-01`;
46
+ const filters = this.getFilters(args.options);
47
+ if (filters.length > 0) {
48
+ url += `&$filter=${filters.join(' and ')}`;
49
+ }
42
50
  try {
43
51
  yield this.getAllItems(url, logger, true);
44
52
  if (this.items.length > 0) {
@@ -59,13 +67,57 @@ class FlowRunListCommand extends AzmgmtItemsListCommand_1.AzmgmtItemsListCommand
59
67
  }
60
68
  });
61
69
  }
70
+ getFilters(options) {
71
+ const filters = [];
72
+ if (options.status) {
73
+ filters.push(`status eq '${options.status}'`);
74
+ }
75
+ if (options.triggerStartTime) {
76
+ filters.push(`startTime ge ${options.triggerStartTime}`);
77
+ }
78
+ if (options.triggerEndTime) {
79
+ filters.push(`startTime lt ${options.triggerEndTime}`);
80
+ }
81
+ return filters;
82
+ }
62
83
  }
63
- _FlowRunListCommand_instances = new WeakSet(), _FlowRunListCommand_initOptions = function _FlowRunListCommand_initOptions() {
84
+ _FlowRunListCommand_instances = new WeakSet(), _FlowRunListCommand_initTelemetry = function _FlowRunListCommand_initTelemetry() {
85
+ this.telemetry.push((args) => {
86
+ Object.assign(this.telemetryProperties, {
87
+ status: typeof args.options.status !== 'undefined',
88
+ triggerStartTime: typeof args.options.triggerStartTime !== 'undefined',
89
+ triggerEndTime: typeof args.options.triggerEndTime !== 'undefined'
90
+ });
91
+ });
92
+ }, _FlowRunListCommand_initOptions = function _FlowRunListCommand_initOptions() {
64
93
  this.options.unshift({
65
94
  option: '-f, --flowName <flowName>'
66
95
  }, {
67
96
  option: '-e, --environmentName <environmentName>'
97
+ }, {
98
+ option: '--status [status]',
99
+ autocomplete: this.allowedStatusses
100
+ }, {
101
+ option: '--triggerStartTime [triggerStartTime]'
102
+ }, {
103
+ option: '--triggerEndTime [triggerEndTime]'
68
104
  });
105
+ }, _FlowRunListCommand_initValidators = function _FlowRunListCommand_initValidators() {
106
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
107
+ if (!validation_1.validation.isValidGuid(args.options.flowName)) {
108
+ return `${args.options.flowName} is not a valid GUID`;
109
+ }
110
+ if (args.options.status && this.allowedStatusses.indexOf(args.options.status) === -1) {
111
+ return `'${args.options.status}' is not a valid status. Allowed values are: ${this.allowedStatusses.join(',')}`;
112
+ }
113
+ if (args.options.triggerStartTime && !validation_1.validation.isValidISODateTime(args.options.triggerStartTime)) {
114
+ return `'${args.options.triggerStartTime}' is not a valid datetime.`;
115
+ }
116
+ if (args.options.triggerEndTime && !validation_1.validation.isValidISODateTime(args.options.triggerEndTime)) {
117
+ return `'${args.options.triggerEndTime}' is not a valid datetime.`;
118
+ }
119
+ return true;
120
+ }));
69
121
  };
70
122
  module.exports = new FlowRunListCommand();
71
123
  //# sourceMappingURL=run-list.js.map
@@ -15,12 +15,12 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _OneNoteNotebookListCommand_instances, _OneNoteNotebookListCommand_initTelemetry, _OneNoteNotebookListCommand_initOptions, _OneNoteNotebookListCommand_initValidators;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- const request_1 = require("../../../../request");
19
18
  const odata_1 = require("../../../../utils/odata");
20
19
  const validation_1 = require("../../../../utils/validation");
21
20
  const aadGroup_1 = require("../../../../utils/aadGroup");
22
21
  const GraphCommand_1 = require("../../../base/GraphCommand");
23
22
  const commands_1 = require("../../commands");
23
+ const spo_1 = require("../../../../utils/spo");
24
24
  class OneNoteNotebookListCommand extends GraphCommand_1.default {
25
25
  get name() {
26
26
  return commands_1.default.NOTEBOOK_LIST;
@@ -62,8 +62,7 @@ class OneNoteNotebookListCommand extends GraphCommand_1.default {
62
62
  });
63
63
  }
64
64
  else if (args.options.webUrl) {
65
- this
66
- .getSpoSiteId(args)
65
+ spo_1.spo.getSpoGraphSiteId(args.options.webUrl)
67
66
  .then((siteId) => {
68
67
  endpoint = `${this.resource}/v1.0/sites/${siteId}/onenote/notebooks`;
69
68
  return resolve(endpoint);
@@ -85,19 +84,6 @@ class OneNoteNotebookListCommand extends GraphCommand_1.default {
85
84
  .getGroupByDisplayName(args.options.groupName)
86
85
  .then(group => group.id);
87
86
  }
88
- getSpoSiteId(args) {
89
- const url = new URL(args.options.webUrl);
90
- const requestOptions = {
91
- url: `${this.resource}/v1.0/sites/${url.hostname}:${url.pathname}`,
92
- headers: {
93
- accept: 'application/json;odata.metadata=none'
94
- },
95
- responseType: 'json'
96
- };
97
- return request_1.default
98
- .get(requestOptions)
99
- .then((site) => site.id);
100
- }
101
87
  commandAction(logger, args) {
102
88
  return __awaiter(this, void 0, void 0, function* () {
103
89
  try {
@@ -15,12 +15,12 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _OneNotePageListCommand_instances, _OneNotePageListCommand_initTelemetry, _OneNotePageListCommand_initOptions, _OneNotePageListCommand_initValidators, _OneNotePageListCommand_initOptionSets;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- const request_1 = require("../../../../request");
19
18
  const odata_1 = require("../../../../utils/odata");
20
19
  const validation_1 = require("../../../../utils/validation");
21
20
  const aadGroup_1 = require("../../../../utils/aadGroup");
22
21
  const GraphCommand_1 = require("../../../base/GraphCommand");
23
22
  const commands_1 = require("../../commands");
23
+ const spo_1 = require("../../../../utils/spo");
24
24
  class OneNotePageListCommand extends GraphCommand_1.default {
25
25
  get name() {
26
26
  return commands_1.default.PAGE_LIST;
@@ -56,7 +56,7 @@ class OneNotePageListCommand extends GraphCommand_1.default {
56
56
  endpoint += `groups/${groupId}`;
57
57
  }
58
58
  else if (args.options.webUrl) {
59
- const siteId = yield this.getSpoSiteId(args.options.webUrl);
59
+ const siteId = yield spo_1.spo.getSpoGraphSiteId(args.options.webUrl);
60
60
  endpoint += `sites/${siteId}`;
61
61
  }
62
62
  else {
@@ -72,20 +72,6 @@ class OneNotePageListCommand extends GraphCommand_1.default {
72
72
  return group.id;
73
73
  });
74
74
  }
75
- getSpoSiteId(webUrl) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- const url = new URL(webUrl);
78
- const requestOptions = {
79
- url: `${this.resource}/v1.0/sites/${url.hostname}:${url.pathname}`,
80
- headers: {
81
- accept: 'application/json;odata.metadata=none'
82
- },
83
- responseType: 'json'
84
- };
85
- const site = yield request_1.default.get(requestOptions);
86
- return site.id;
87
- });
88
- }
89
75
  commandAction(logger, args) {
90
76
  return __awaiter(this, void 0, void 0, function* () {
91
77
  try {
@@ -22,6 +22,7 @@ const request_1 = require("../../../../request");
22
22
  const GraphCommand_1 = require("../../../base/GraphCommand");
23
23
  const commands_1 = require("../../commands");
24
24
  const formatting_1 = require("../../../../utils/formatting");
25
+ const accessToken_1 = require("../../../../utils/accessToken");
25
26
  class OutlookMailSendCommand extends GraphCommand_1.default {
26
27
  get name() {
27
28
  return commands_1.default.MAIL_SEND;
@@ -40,8 +41,8 @@ class OutlookMailSendCommand extends GraphCommand_1.default {
40
41
  commandAction(logger, args) {
41
42
  return __awaiter(this, void 0, void 0, function* () {
42
43
  try {
43
- const isAppOnlyAuth = Auth_1.Auth.isAppOnlyAuth(Auth_1.default.service.accessTokens[this.resource].accessToken);
44
- if (isAppOnlyAuth === true && !args.options.sender) {
44
+ const isAppOnlyAccessToken = accessToken_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken);
45
+ if (isAppOnlyAccessToken === true && !args.options.sender) {
45
46
  throw `Specify a upn or user id in the 'sender' option when using app only authentication.`;
46
47
  }
47
48
  const requestOptions = {
@@ -17,6 +17,7 @@ var _OutlookMessageGetCommand_instances, _OutlookMessageGetCommand_initTelemetry
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const Auth_1 = require("../../../../Auth");
19
19
  const request_1 = require("../../../../request");
20
+ const accessToken_1 = require("../../../../utils/accessToken");
20
21
  const GraphCommand_1 = require("../../../base/GraphCommand");
21
22
  const commands_1 = require("../../commands");
22
23
  class OutlookMessageGetCommand extends GraphCommand_1.default {
@@ -35,12 +36,12 @@ class OutlookMessageGetCommand extends GraphCommand_1.default {
35
36
  commandAction(logger, args) {
36
37
  return __awaiter(this, void 0, void 0, function* () {
37
38
  try {
38
- const isAppOnlyAuth = Auth_1.Auth.isAppOnlyAuth(Auth_1.default.service.accessTokens[this.resource].accessToken);
39
+ const isAppOnlyAccessToken = accessToken_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken);
39
40
  if (this.verbose) {
40
- logger.logToStderr(`Retrieving message with id ${args.options.id} using ${isAppOnlyAuth ? 'app only permissions' : 'delegated permissions'}`);
41
+ logger.logToStderr(`Retrieving message with id ${args.options.id} using ${isAppOnlyAccessToken ? 'app only permissions' : 'delegated permissions'}`);
41
42
  }
42
43
  let requestUrl = '';
43
- if (isAppOnlyAuth) {
44
+ if (isAppOnlyAccessToken) {
44
45
  if (!args.options.userId && !args.options.userPrincipalName) {
45
46
  throw `The option 'userId' or 'userPrincipalName' is required when retrieving an email using app only credentials`;
46
47
  }
@@ -0,0 +1,47 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const request_1 = require("../../../../request");
13
+ const GraphCommand_1 = require("../../../base/GraphCommand");
14
+ const commands_1 = require("../../commands");
15
+ class PlannerRosterAddCommand extends GraphCommand_1.default {
16
+ get name() {
17
+ return commands_1.default.ROSTER_ADD;
18
+ }
19
+ get description() {
20
+ return 'Creates a new Microsoft Planner Roster';
21
+ }
22
+ commandAction(logger) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ if (this.verbose) {
25
+ logger.logToStderr('Creating a new Microsoft Planner Roster');
26
+ }
27
+ try {
28
+ const requestBody = {};
29
+ const requestOptions = {
30
+ url: `${this.resource}/beta/planner/rosters`,
31
+ headers: {
32
+ accept: 'application/json;odata.metadata=none'
33
+ },
34
+ data: requestBody,
35
+ responseType: 'json'
36
+ };
37
+ const response = yield request_1.default.post(requestOptions);
38
+ logger.log(response);
39
+ }
40
+ catch (err) {
41
+ this.handleRejectedODataJsonPromise(err);
42
+ }
43
+ });
44
+ }
45
+ }
46
+ module.exports = new PlannerRosterAddCommand();
47
+ //# sourceMappingURL=roster-add.js.map
@@ -0,0 +1,88 @@
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 _PlannerRosterRemoveCommand_instances, _PlannerRosterRemoveCommand_initTelemetry, _PlannerRosterRemoveCommand_initOptions;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
19
+ const request_1 = require("../../../../request");
20
+ const GraphCommand_1 = require("../../../base/GraphCommand");
21
+ const commands_1 = require("../../commands");
22
+ class PlannerRosterRemoveCommand extends GraphCommand_1.default {
23
+ get name() {
24
+ return commands_1.default.ROSTER_REMOVE;
25
+ }
26
+ get description() {
27
+ return 'Removes a Microsoft Planner Roster';
28
+ }
29
+ constructor() {
30
+ super();
31
+ _PlannerRosterRemoveCommand_instances.add(this);
32
+ __classPrivateFieldGet(this, _PlannerRosterRemoveCommand_instances, "m", _PlannerRosterRemoveCommand_initTelemetry).call(this);
33
+ __classPrivateFieldGet(this, _PlannerRosterRemoveCommand_instances, "m", _PlannerRosterRemoveCommand_initOptions).call(this);
34
+ }
35
+ commandAction(logger, args) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ if (args.options.confirm) {
38
+ yield this.removeRoster(args, logger);
39
+ }
40
+ else {
41
+ const result = yield Cli_1.Cli.prompt({
42
+ type: 'confirm',
43
+ name: 'continue',
44
+ default: false,
45
+ message: `Are you sure you want to remove roster ${args.options.id}?`
46
+ });
47
+ if (result.continue) {
48
+ yield this.removeRoster(args, logger);
49
+ }
50
+ }
51
+ });
52
+ }
53
+ removeRoster(args, logger) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ if (this.verbose) {
56
+ logger.logToStderr(`Removing roster ${args.options.id}`);
57
+ }
58
+ try {
59
+ const requestOptions = {
60
+ url: `${this.resource}/beta/planner/rosters/${args.options.id}`,
61
+ headers: {
62
+ accept: 'application/json;odata.metadata=none'
63
+ },
64
+ responseType: 'json'
65
+ };
66
+ yield request_1.default.delete(requestOptions);
67
+ }
68
+ catch (err) {
69
+ this.handleRejectedODataJsonPromise(err);
70
+ }
71
+ });
72
+ }
73
+ }
74
+ _PlannerRosterRemoveCommand_instances = new WeakSet(), _PlannerRosterRemoveCommand_initTelemetry = function _PlannerRosterRemoveCommand_initTelemetry() {
75
+ this.telemetry.push((args) => {
76
+ Object.assign(this.telemetryProperties, {
77
+ confirm: !!args.options.confirm
78
+ });
79
+ });
80
+ }, _PlannerRosterRemoveCommand_initOptions = function _PlannerRosterRemoveCommand_initOptions() {
81
+ this.options.unshift({
82
+ option: '--id <id>'
83
+ }, {
84
+ option: '--confirm'
85
+ });
86
+ };
87
+ module.exports = new PlannerRosterRemoveCommand();
88
+ //# sourceMappingURL=roster-remove.js.map
@@ -12,6 +12,8 @@ exports.default = {
12
12
  PLAN_LIST: `${prefix} plan list`,
13
13
  PLAN_REMOVE: `${prefix} plan remove`,
14
14
  PLAN_SET: `${prefix} plan set`,
15
+ ROSTER_ADD: `${prefix} roster add`,
16
+ ROSTER_REMOVE: `${prefix} roster remove`,
15
17
  TASK_ADD: `${prefix} task add`,
16
18
  TASK_CHECKLISTITEM_ADD: `${prefix} task checklistitem add`,
17
19
  TASK_CHECKLISTITEM_LIST: `${prefix} task checklistitem list`,
@@ -38,6 +38,7 @@ class SpoNavigationNodeAddCommand extends SpoCommand_1.default {
38
38
  return ['url'];
39
39
  }
40
40
  commandAction(logger, args) {
41
+ var _a;
41
42
  return __awaiter(this, void 0, void 0, function* () {
42
43
  if (this.verbose) {
43
44
  logger.logToStderr(`Adding navigation node...`);
@@ -51,12 +52,13 @@ class SpoNavigationNodeAddCommand extends SpoCommand_1.default {
51
52
  accept: 'application/json;odata=nometadata',
52
53
  'content-type': 'application/json;odata=nometadata'
53
54
  },
55
+ responseType: 'json',
54
56
  data: {
57
+ AudienceIds: (_a = args.options.audienceIds) === null || _a === void 0 ? void 0 : _a.split(','),
55
58
  Title: args.options.title,
56
59
  Url: args.options.url,
57
60
  IsExternal: args.options.isExternal === true
58
- },
59
- responseType: 'json'
61
+ }
60
62
  };
61
63
  try {
62
64
  const res = yield request_1.default.post(requestOptions);
@@ -73,7 +75,8 @@ _SpoNavigationNodeAddCommand_instances = new WeakSet(), _SpoNavigationNodeAddCom
73
75
  Object.assign(this.telemetryProperties, {
74
76
  isExternal: args.options.isExternal,
75
77
  location: typeof args.options.location !== 'undefined',
76
- parentNodeId: typeof args.options.parentNodeId !== 'undefined'
78
+ parentNodeId: typeof args.options.parentNodeId !== 'undefined',
79
+ audienceIds: typeof args.options.audienceIds !== 'undefined'
77
80
  });
78
81
  });
79
82
  }, _SpoNavigationNodeAddCommand_initOptions = function _SpoNavigationNodeAddCommand_initOptions() {
@@ -90,6 +93,8 @@ _SpoNavigationNodeAddCommand_instances = new WeakSet(), _SpoNavigationNodeAddCom
90
93
  option: '--parentNodeId [parentNodeId]'
91
94
  }, {
92
95
  option: '--isExternal'
96
+ }, {
97
+ option: '--audienceIds [audienceIds]'
93
98
  });
94
99
  }, _SpoNavigationNodeAddCommand_initValidators = function _SpoNavigationNodeAddCommand_initValidators() {
95
100
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
@@ -108,6 +113,15 @@ _SpoNavigationNodeAddCommand_instances = new WeakSet(), _SpoNavigationNodeAddCom
108
113
  return `${args.options.location} is not a valid value for the location option. Allowed values are QuickLaunch|TopNavigationBar`;
109
114
  }
110
115
  }
116
+ if (args.options.audienceIds) {
117
+ const audienceIdsSplitted = args.options.audienceIds.split(',');
118
+ if (audienceIdsSplitted.length > 10) {
119
+ return 'The maximum amount of audienceIds per navigation node exceeded. The maximum amount of auciendeIds is 10.';
120
+ }
121
+ if (!validation_1.validation.isValidGuidArray(audienceIdsSplitted)) {
122
+ return 'The option audienceIds contains one or more invalid GUIDs';
123
+ }
124
+ }
111
125
  return true;
112
126
  }));
113
127
  }, _SpoNavigationNodeAddCommand_initOptionSets = function _SpoNavigationNodeAddCommand_initOptionSets() {
@@ -26,6 +26,9 @@ class SpoNavigationNodeListCommand extends SpoCommand_1.default {
26
26
  get description() {
27
27
  return 'Lists nodes from the specified site navigation';
28
28
  }
29
+ defaultProperties() {
30
+ return ['Id', 'Title', 'Url'];
31
+ }
29
32
  constructor() {
30
33
  super();
31
34
  _SpoNavigationNodeListCommand_instances.add(this);
@@ -40,13 +43,7 @@ class SpoNavigationNodeListCommand extends SpoCommand_1.default {
40
43
  }
41
44
  try {
42
45
  const res = yield odata_1.odata.getAllItems(`${args.options.webUrl}/_api/web/navigation/${args.options.location.toLowerCase()}`);
43
- logger.log(res.map(n => {
44
- return {
45
- Id: n.Id,
46
- Title: n.Title,
47
- Url: n.Url
48
- };
49
- }));
46
+ logger.log(res);
50
47
  }
51
48
  catch (err) {
52
49
  this.handleRejectedODataJsonPromise(err);
@@ -0,0 +1,118 @@
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 _SpoNavigationNodeSetCommand_instances, _SpoNavigationNodeSetCommand_initTelemetry, _SpoNavigationNodeSetCommand_initTypes, _SpoNavigationNodeSetCommand_initOptions, _SpoNavigationNodeSetCommand_initValidators;
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
+ class SpoNavigationNodeSetCommand extends SpoCommand_1.default {
23
+ get name() {
24
+ return commands_1.default.NAVIGATION_NODE_SET;
25
+ }
26
+ get description() {
27
+ return 'Adds a navigation node to the specified site navigation';
28
+ }
29
+ constructor() {
30
+ super();
31
+ _SpoNavigationNodeSetCommand_instances.add(this);
32
+ __classPrivateFieldGet(this, _SpoNavigationNodeSetCommand_instances, "m", _SpoNavigationNodeSetCommand_initTelemetry).call(this);
33
+ __classPrivateFieldGet(this, _SpoNavigationNodeSetCommand_instances, "m", _SpoNavigationNodeSetCommand_initOptions).call(this);
34
+ __classPrivateFieldGet(this, _SpoNavigationNodeSetCommand_instances, "m", _SpoNavigationNodeSetCommand_initTypes).call(this);
35
+ __classPrivateFieldGet(this, _SpoNavigationNodeSetCommand_instances, "m", _SpoNavigationNodeSetCommand_initValidators).call(this);
36
+ }
37
+ commandAction(logger, args) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ try {
40
+ if (this.verbose) {
41
+ logger.logToStderr(`Setting navigation node...`);
42
+ }
43
+ const requestBody = {
44
+ Title: args.options.title,
45
+ IsExternal: args.options.isExternal,
46
+ Url: args.options.url
47
+ };
48
+ if (args.options.audienceIds !== undefined) {
49
+ requestBody.AudienceIds = args.options.audienceIds === '' ? [] : args.options.audienceIds.split(',');
50
+ }
51
+ const requestOptions = {
52
+ url: `${args.options.webUrl}/_api/web/navigation/GetNodeById(${args.options.id})`,
53
+ headers: {
54
+ accept: 'application/json;odata=nometadata',
55
+ 'content-type': 'application/json;odata=nometadata'
56
+ },
57
+ data: requestBody,
58
+ responseType: 'json'
59
+ };
60
+ const response = yield request_1.default.patch(requestOptions);
61
+ if (response['odata.null'] === true) {
62
+ throw `Navigation node does not exist.`;
63
+ }
64
+ }
65
+ catch (err) {
66
+ this.handleRejectedODataJsonPromise(err);
67
+ }
68
+ });
69
+ }
70
+ }
71
+ _SpoNavigationNodeSetCommand_instances = new WeakSet(), _SpoNavigationNodeSetCommand_initTelemetry = function _SpoNavigationNodeSetCommand_initTelemetry() {
72
+ this.telemetry.push((args) => {
73
+ Object.assign(this.telemetryProperties, {
74
+ title: typeof args.options.title !== 'undefined',
75
+ url: typeof args.options.url !== 'undefined',
76
+ isExternal: typeof args.options.isExternal !== 'undefined',
77
+ audienceIds: typeof args.options.audienceIds !== 'undefined'
78
+ });
79
+ });
80
+ }, _SpoNavigationNodeSetCommand_initTypes = function _SpoNavigationNodeSetCommand_initTypes() {
81
+ this.types.boolean.push('isExternal');
82
+ }, _SpoNavigationNodeSetCommand_initOptions = function _SpoNavigationNodeSetCommand_initOptions() {
83
+ this.options.unshift({
84
+ option: '-u, --webUrl <webUrl>'
85
+ }, {
86
+ option: '--id <id>'
87
+ }, {
88
+ option: '--title [title]'
89
+ }, {
90
+ option: '--url [url]'
91
+ }, {
92
+ option: '--audienceIds [audienceIds]'
93
+ }, {
94
+ option: '--isExternal [isExternal]'
95
+ });
96
+ }, _SpoNavigationNodeSetCommand_initValidators = function _SpoNavigationNodeSetCommand_initValidators() {
97
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
98
+ const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
99
+ if (isValidSharePointUrl !== true) {
100
+ return isValidSharePointUrl;
101
+ }
102
+ if (args.options.audienceIds === undefined && !args.options.url && args.options.isExternal === undefined && !args.options.title) {
103
+ return `Please specify atleast one property to update.`;
104
+ }
105
+ if (args.options.audienceIds) {
106
+ const audienceIdsSplitted = args.options.audienceIds.split(',');
107
+ if (audienceIdsSplitted.length > 10) {
108
+ return 'The maximum amount of audienceIds per navigation node exceeded. The maximum amount of audienceIds is 10.';
109
+ }
110
+ if (!validation_1.validation.isValidGuidArray(audienceIdsSplitted)) {
111
+ return `The option audienceIds contains one or more invalid GUIDs`;
112
+ }
113
+ }
114
+ return true;
115
+ }));
116
+ };
117
+ module.exports = new SpoNavigationNodeSetCommand();
118
+ //# sourceMappingURL=navigation-node-set.js.map